2021年4月9日星期五

How to combine two list in a specific order, i have two list

i am trying to combine two list in a specific order how?

list_1=[[1,2,3,4],[6,7,8,9],[11,12,13,14],]  list_2=[[5],[10],[15]]  answer=[]  for numbers in list_1:      answer.append(numbers)      for j in range(1):          answer.append(list_2[i+j])      i += j+1`  

my_output

[[1, 2, 3, 4], [5], [6, 7, 8, 9], [10], [11, 12, 13, 14], [15]]  

expected output

[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]  
https://stackoverflow.com/questions/67030522/how-to-combine-two-list-in-a-specific-order-i-have-two-list April 10, 2021 at 11:26AM

没有评论:

发表评论