On Jun 10, 2:39 am, james_027 <[email protected]> wrote:
> hi,
>
> I am trying to reverse the order of my list of tuples and its is
> returning a None to me. Is the reverse() function not allow on list
> containing tuples?
>
> Thanks,
> James
As the others already mentioned list.reverse() is in-place, just as
for
example list.sort(). Alternatively, use the builtin reversed() or
sorted()
functions to get a return value (they will leave the original list
unmodified.
Example:
>>> a = range(3)
>>> b = reversed(a)
>>> for item in b:
...print item
This will produce:
2
1
0
Note that reversed returns an iterator.
Marco
--
http://mail.python.org/mailman/listinfo/python-list