0
Reversing a list by slicing
I learned that using [::-1] reverses a list. But if I am not wrong, the first argument in [ : : ] is by default 0, i.e. start of list and second argument is by default end of list i.e., -1. So shouldn't [::-1] just return the first element followed by the last?
1 Answer
0
-1 is the step i.e [start:end:step]
[::-1] means
From the first argument in the list to the last with a step of -1.