This is an index of the list, it returns all the elements [:] , with the exception of the last -1 . Similar question here
For example,
>>> a = [1,2,3,4,5,6] >>> a[:-1] [1, 2, 3, 4, 5]
It works as follows
a[start:end]
>>> a[1:2] [2]
a[start:]
>>> a[1:] [2, 3, 4, 5, 6]
a[:end]
Your case
>>> a = [1,2,3,4,5,6] >>> a[:-1] [1, 2, 3, 4, 5]
a[:]
>>> a[:] [1, 2, 3, 4, 5, 6]
enginefree
source share