Liste Python sauf le dernier élément
>>> myList = list(range(1,5))
>>> myList
[1, 2, 3, 4]
>>> myList = myList[:-1]
>>> myList
[1, 2, 3]
Exypnos
>>> myList = list(range(1,5))
>>> myList
[1, 2, 3, 4]
>>> myList = myList[:-1]
>>> myList
[1, 2, 3]
>>> some_list = [1, 2, 3]
>>> some_list[-1] = 5 # Set the last element
>>> some_list[-2] = 3 # Set the second to last element
>>> some_list
[1, 3, 5]
x = [1, 2, 3, 4]
#same array, but the last item.
notLast = x[0:-1]
MyList = [1, 2, 3, 4, 5]
print(MyList[len(Mylist)-1])
# Makes you look professional