I have a list of lists:
[['John', 'Sergeant '], ['Jack', 'Commander '], ['Jill', 'Captain ']]
How can I merge it with a single list like:
['800','854','453']
So that the end result looks like:
[['John', 'Sergeant', '800'], ['Jack', 'Commander', '854'], ['Jill', 'Captain', '453']]
Initially I tried:
zip(list_with_lists,list)
but data was obfuscated
a = [['John', 'Sergeant '], ['Jack', 'Commander '], ['Jill', 'Captain ']]
b = ['800', '854', '453']
c = [x+[y] for x,y in zip(a,b)]
print c
Result:
[['John', 'Sergeant ', '800'], ['Jack', 'Commander ', '854'], ['Jill', 'Captain ', '453']]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With