-2

Im have 2 arrays, for example: [1, 2, 3] and [4, 5, 6] How do i merge them into 1 array?: [1, 4, 2, 5, 3, 6] ? help please

1 Answers1

1

If the order is not important can just use +:

a = [1, 2, 3]
b = [4, 5, 6]
c = a + b

Otherwise you can do something like this:

a = [1, 2, 3]
b = [4, 5, 6]
c = []
for i, j in zip(a, b):
    c += [i, j]
Pavel Botsman
  • 773
  • 1
  • 11
  • 25