Questions about tuple?
Mindy
csshi99 at yahoo.com
Fri Nov 8 19:27:11 EST 2002
Hey, given a tuple t(a,b), is there any function in
Python that I can get a, b individually from t?
Actually, I have a list whose element is tuples. Say:
tuple_list = [(1,'a'),(3,'b'),(2,'l'),(8,'p')]
Then I want to get two lists from this tuple_list. The
first list contains the first elements in the tuple of
the tuple_list.
first_list = [1,3,2,8]
And the second list contains all the second elements,
also maintaining the original order as in tuple_list.
second_list = ['a','b','l','p']
So how to get this easily? Thanks!
=====
Cheers
-Mindy
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
More information about the Python-list
mailing list