How to reverse tuples in a list?

Paul Rubin http
Tue Aug 8 22:26:58 EDT 2006


"Noah" <noah at noah.org> writes:
> I know I could do this long-form:
>     q = []
>     y = [('a', 1.0), ('b', 2.0), ('c', 3.0)]
> ...

y = [tuple(reversed(t)) for t in y]



More information about the Python-list mailing list