read last element of list python code example

Example 1: access last element of list python

MyList=["Black","Blue","Red","Green"]
print(MyList[-1])

Example 2: python get last element of list

mylist = [0, 1, 2]
mylist[-1] = 3 # sets last element
print(myList[-1]) # prints Last element

Example 3: how to get the last value in a list python

your_list = ["apple", "orange", "grapes"]
last_value = your_list[-1]

Example 4: python last element of list

>>> list[-1:] # returns indexed value
    [3]
>>> list[-1]  # returns value
    3