Letzte Element in List 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]
if x == my_list[-1]:
# do what you want
array = ["a", "b", "c", "d"]
num_elements = 3
print(array[-num_elements:])
list = [4,3,2,5,4]
last=list[len(list)-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