Source Code:
(back to article)
my_list = [1, 2, 3, 4, 5] # Get the index of the last element last_index = len(my_list) - 1 # Get the last element last_element = my_list[last_index] print(last_element) # Output: 5
Result:
Report an issue