Последний элемент в списке py
l = [1,2,3,4,5]
last = l[len(l)-1]
Wild Wildebeest
l = [1,2,3,4,5]
last = l[len(l)-1]
lst = [2, 5 , 6, 3, 8, 9]
n = len(lst) #get the length
last_el = lst[n-1] #get the last element
print("The last element of the list is:", last_el)
some_list = [1, 2, 3]
some_list[-1]
print(some_list)
#Output = 3
list1 = ['a','b','c']
print(list1[-1])
your_list = ["apple", "orange", "grapes"]
last_value = your_list[-1]
some_list = [1,2,3]
some_list[-1] is the shortest and most Pythonic.
#output = 3