python for loop get last item in the list code example
Example 1: access last element of list python
MyList=["Black","Blue","Red","Green"]
print(MyList[-1])
Example 2: python get last element in list
l = [1, 2, 3]
l[-1]
MyList=["Black","Blue","Red","Green"]
print(MyList[-1])
l = [1, 2, 3]
l[-1]