logo
  • Python
    • python libraries
    • python tutorial
  • Django
    • django snippet
    • django tutorial
  • About
  • Contact

Last modified: February 20, 2020

getting the last item of list python

syntax

1
your_list[-1]

example

1
2
3
a_list= ['elephant', 'dog', 'cat', 'zebra']

print(a_list[-1])

output

1
zebra
back to top

Recent Posts:

  • BeautifulSoup: Extract the Contents of Element
  • BeautifulSoup: Get the aria-label attribute
  • Python: Add Variable to String & Print Using 4 Methods
  • Get Country From Ip in Python
  • Get my Public IP in Python
  • Currency conversion in python

Related Posts:

  • Get Random Country in Python
  • inline if statement python
  • How to make a random string in python
  • Sorting a List in Python with example

© 2021