I can’t find any information on [::-1]. In the wikibooks python tutorial, there is a section about non-continous lists, but there’s no information on parameters < 0. Effects are clear, but how do you explain it?
Example Usage:
>>> foo = [1, 2, 3]
>>> foo[::-1]
[3, 2, 1]
The syntax is as follows:
So
foo[::-1]meansentire list with step=-1, so actually reversing the list.See this answer for detailed explanation.