change the stuff to list of tuples

Raymond Hettinger vze4rx4y at verizon.net
Tue May 27 01:27:34 EDT 2003


"anson" <aeze616 at cse.unsw.edu.au> wrote in message
news:cb7ba330.0305262003.1f8f1708 at posting.google.com...
> Dear people,
>
>   I have three lists:
>    [1,2,3]
>    ['a','b','c']
>    ['d','e','f']
>
>   How do I combine the list to become this (in one step if possible)?
>
>    [(1,'a','d'),(2,'b','e'), (3,'c','f')]


>>> a = [1,2,3]
>>> b = ['a','b','c']
>>> c = ['d','e','f']
>>>
>>> zip(a,b,c)
[(1, 'a', 'd'), (2, 'b', 'e'), (3, 'c', 'f')]


Raymond Hettinger







More information about the Python-list mailing list