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:
...print item
This will produce:
2
1
0
Note that reversed returns an iterator.
Marco
How about just doing it the old fashioned way via slicing.
foo = (4,5,8,2,9,1,6)
foo[::-1] (6, 1, 9, 2, 8, 5, 4)
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Fedora -
http://enigmail.mozdev.org/
iEYEARECAAYFAkwRCgwACgkQRIVy4fC+NyTCswCdFI3RV1m6eTEvfMo314Dklc6U
9rkAn1j+zYNzNR4gB5WWajVns6B+P74o
=ALG4
-----END PGP SIGNATURE-----