last element of an array python code example
Example 1: python last element in list
bikes = ['trek', 'redline', 'giant']
bikes[-1]
Example 2: get last element of array python
some_list[-1]
Example 3: how to get last element of list in python
MyList = [1, 2, 3, 4, 5]
print(MyList[len(Mylist)-1])
Example 4: get the last element of a list python
print(list[-1])
Example 5: how to access the last element of a list in python
l = [1, 2, 3, 4, 5]
print(l[-1])
Example 6: python list last element
my_list = ['red', 'blue', 'green']
last_item = my_list[len(my_list) - 1]
last_item = my_list.pop()
last_item = my_list[-1]
*_, last_item = my_list