Questions about tuple?
Kevin@Cazabon.com
kevin at cazabon.com
Fri Nov 8 23:16:54 EST 2002
It's called a dictionary.
dict = {"a":1, "b":3, "l":2, "p":8, "m":(1,2,3,4,5), "z":"blah"}
dict.keys()
>>> ("a", "b", "l", "p","m","z")
dict.values()
>>> (1,3,2,8,(1,2,3,4,5),"blah")
dict["a"]
>>>1
Kevin.
"Mindy" <csshi99 at yahoo.com> wrote in message
news:mailman.1036801694.17667.python-list at python.org...
> 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