How to merge elements of a list and nested list in Python

1 Answer

0 votes
lst1 = [['a', 1], ['b', 2], ['c', 3], ['d', 4]]
lst2 = [30, 40, 50, 90, 100]

merge_list = [x + [y] for x, y in zip(lst1, lst2)]

print(merge_list)  


     
     
     
'''
run:
     
[['a', 1, 30], ['b', 2, 40], ['c', 3, 50], ['d', 4, 90]]
   
'''

 



answered Feb 20, 2023 by avibootz
...