Possible Duplicate:
Python - merge items of two lists into a list of tuples
There are two lists
x = [1,2,3,4,5]
y = ['a','b','c','d','e']
How can I get the list
z = [(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')]
Possible Duplicate:
Python - merge items of two lists into a list of tuples
There are two lists
x = [1,2,3,4,5]
y = ['a','b','c','d','e']
How can I get the list
z = [(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')]
z = zip(x,y)
will do your job.
>>> x = [1,2,3,4,5]
>>> y = ['a','b','c','d','e']
>>> z = zip(x,y)
>>> z
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')]
Given your input, the builtin function zip(x, y)
will provide the output, that you want.