Skip to content
Sign upLog in
← Back to Community

How to Get the Last Element of a List In Python

Profile icon
catchsrinivas

Method 1 – By Iterating all the elements in a list

The most common and straightforward way to get last element in list is through iterating the entire element till it reaches the last element, as shown in repl.

For other ways Checkout the post How to Get the Last Element of a List In Python

Voters
Profile icon
catchsrinivas
Comments
hotnewtop
Profile icon
MrVoo

Actually, the most common and easiest way is listName[-1]

Profile icon
IMayBeMe

@MrVoo
I second this

Profile icon
CodingElf66

@MrVoo
Haha you're right lol. Tutorial saying wrong stuff.