How to get last element in python?
Last element
Started by webmag, Nov 21 2010 06:58 AM
1 reply to this topic
#1
Posted 21 November 2010 - 06:58 AM
|
|
|
#2
Posted 21 November 2010 - 07:03 AM
Hi,
The simplest way is:
The simplest way is:
your_var[-1]But you can also try:
your_var.pop()
Quote
Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)


Sign In
Create Account

Back to top









