Re:Python iteration
by dalke on Wednesday April 25, 2012 @04:33PM
(#3890926)
No. They start from the beginning and go to the end. Conceptually it could work on any iterable, and not just a list container.
You can, however, use the 'reversed()' function, as in "for row in reversed(rows): for col in reversed(row): print col"
There is a special double-underscore method, which lists and other data structures support, to allow iteration in reverse with the normal performance of forward iteration.
You can, however, use the 'reversed()' function, as in "for row in reversed(rows): for col in reversed(row): print col"
There is a special double-underscore method, which lists and other data structures support, to allow iteration in reverse with the normal performance of forward iteration.