Next / Previous / Contents / TCC Help System / NM Tech homepage

20.36. reversed(): Produce a reverse iterator

This function, applied to a sequence S, returns an iterator that generates the elements of S in reverse order (see Section 24.2, “Iterators: Values that can produce a sequence of values”).

>>> L=[22,44,88]
>>> backL = reversed(L)
>>> for i in backL:
...     print i,
88 44 22

The allowable values for S include all the types described in Section 8, “Sequence types”. It also works for any class provided one of these two conditions is met: