Skip to content

Instantly share code, notes, and snippets.

@rpivo
Created January 17, 2021 21:06
Show Gist options
  • Save rpivo/cc0ae58e318c41cd7bbabae2319f2d7b to your computer and use it in GitHub Desktop.
Save rpivo/cc0ae58e318c41cd7bbabae2319f2d7b to your computer and use it in GitHub Desktop.
Getting the Last Item in a List in Python

Getting the Last Item in a List in Python

You can get the last item in a list by using -1 as the index.

l = [1,2,3,4,5]

print(l[-1]) # 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment