get last position in array python code example
Example 1: get last element of a list python
a = [1, 2, 3, 4]
print(a[-1])
#prints: 4
print(a[-2])
#prints: 3
Example 2: python get last element of list
mylist = [0, 1, 2]
mylist[-1] = 3 # sets last element
print(myList[-1]) # prints Last element