python get second last item in list code example
Example 1: python get last element in list
l = [1, 2, 3]
l[-1]
Example 2: get last element of a list python
a = [1, 2, 3, 4]
print(a[-1])
#prints: 4
print(a[-2])
#prints: 3
l = [1, 2, 3]
l[-1]
a = [1, 2, 3, 4]
print(a[-1])
#prints: 4
print(a[-2])
#prints: 3