list how to check for last element code example
Example 1: python get last element of list
mylist = [0, 1, 2]
mylist[-1] = 3 # sets last element
print(myList[-1]) # prints Last element
Example 2: check if is the last element in list python
if x == my_list[-1]:
# do what you want