Suppose I\'ve the following list:
list1 = [1, 2, 33, 51] ^ | indices 0 1 2 3
How do I obtain the
the best and fast way to obtain last index of a list is using -1 for number of index , for example:
-1
my_list = [0, 1, 'test', 2, 'hi'] print(my_list[-1])
out put is : 'hi'. index -1 in show you last index or first index of the end.
'hi'