Simple example on how to get the last element of a list in python
>>> a = [5,2,7,8]
>>> a[-1] # gets the last element
8
Another example on how to get the last but one element of a list in python:
>>> a[-2] # gets the second to last
7
References
Liens | Site |
---|---|
Data Structures | Python Doc |
How to get the last element of a list? | stackoverflow |
How to get last items of a list in Python? | stackoverflow |
Python first and last element from array | stackoverflow |
Getting the last element of a list in Python | stackoverflow |
Sélectionner le dernier élément d'une liste python | science-emergence |