python check if is the last element in list code example
Example 1: how to access the last element of a list in python
l = [1, 2, 3, 4, 5]
print(l[-1])
Example 2: check if is the last element in list python
if x == my_list[-1]:
# do what you want