Python, matching items in 2 lists

I have 2 lists that have the equal amount of integers inside

A = [1,2,3]
B = [4,5,6]

I want to match the items in numerical order. So I want a result like

C = [4,1,5,2,6,3]

Is it possible to create a function that returns a value like this ?
Thank you so much.

>Solution :

You can use zip to make this

def merge_lists(list_a, list_b):
  merged = []
  for pair in zip(list_a, list_b)
  return merged

Leave a Reply