sorry ... i replied to sender instead of all ... so here we go again ... >>>t = [('a', 1.0), ('b',2.0),('c',3.0)] >>>t = [s[::-1] for s in t] >>>print t [(1.0, 'a'), (2.0, 'b'), (3.0, 'c')] >>>
>From: "Paul McGuire" <[EMAIL PROTECTED]> >To: python-list@python.org >Subject: Re: How to reverse tuples in a list? >Date: Wed, 09 Aug 2006 01:28:05 GMT > >"Noah" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] > > I have a list of tuples > > [('a', 1.0), ('b', 2.0), ('c', 3.0)] > > I want to reverse the order of the elements inside the tuples. > > [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] > > > > >>> tups = [('a', 1.0), ('b', 2.0), ('c', 3.0)] > >>> map(tuple,map(reversed,tups)) >[(1.0, 'a'), (2.0, 'b'), (3.0, 'c')] > > >-- >http://mail.python.org/mailman/listinfo/python-list _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ -- http://mail.python.org/mailman/listinfo/python-list