merge list of tuples with list

Daniel Wagner brocki2301 at googlemail.com
Tue Oct 19 23:10:27 EDT 2010


I used the following code to add a single fixed value to both tuples.
But this is still not what I want...
>>>a = [(1,2,3), (4,5,6)]
>>>b = 1
>>>a = map(tuple, map(lambda x: x + [1], map(list, a)))
>>>a
[(1, 2, 3, 1), (4, 5, 6, 1)]

What I need is:
>>>a = [(1,2,3), (4,5,6)]
>>>b = (7,8)
>>> a = CODE
>>>a
[(1,2,3,7), (4,5,6,8)]

Greetings,
Daniel



More information about the Python-list mailing list