Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

How to Get the Last Element of a List In Python

catchsrinivas
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

1 year ago

Voters

Comments

TopNew
1
MrVoo
MrVoo

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

1 year ago
2
IMayBeMe
IMayBeMe

@MrVoo
I second this

1 year ago
1
CodingElf66
CodingElf66

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

1 year ago
Load more