get all elements except last python code example
Example 1: python list except last element
>>> myList = list(range(1,5))
>>> myList
[1, 2, 3, 4]
>>> myList = myList[:-1]
>>> myList
[1, 2, 3]
Example 2: get every item but the last item of python list
x = [1, 2, 3, 4]
#same array, but the last item.
notLast = x[0:-1]