Mandeyo
Mandeyo

Reputation: 181

Python : Appending items from 2D list to another 2D list at same indexes

first_list=[[2,3],[],[1,3],[]]
second_list=[[1,2,3],[1,2,3],[1,2,3],[1,2,3]]

I want to append the numbers of the first list to the second list at the same indexes. This should return:

[[1,2,3,2,3],[1,2,3],[1,2,3,1,3],[1,2,3]]

This seems complicated and I'm just a beginner at python.. please give me some help on how to approach this!

Upvotes: 0

Views: 130

Answers (1)

v.coder
v.coder

Reputation: 1932

I am just adding the answer here:

[x+y for x,y in zip(second_list,first_list)]

Upvotes: 1

Related Questions