Skip to main content

Command Palette

Search for a command to run...

how to get the last item of a python list

Updated
1 min readView as Markdown
D

Owner of howtouselinux.com. I work as a Linux engineer for over 20 years. Now I am a technical blogger and Software Engineer. I enjoy sharing learning and contributing to open-source.

>>> list1 = [1, 2, 3, 4, 5]
>>> print(list1[len(list1)-1])
5
>>> print(list1[-1])
5
>>> print(list1.pop())
5
>>>

how to get the last element of a list in python

More from this blog

Linux Skills

26 posts