-2

If I have the following lists:

a = ['a','b','c']
b = ['1','2','3']

How can I get python to output this:

['a',1,'b',2,'c',3]

Thanks in advance !!

Abdul Niyas P M
  • 18,035
  • 2
  • 25
  • 46

1 Answers1

0

Try this:

a = ['a', 'b', 'c']
b = ['1', '2', '3']

c = []
for x, y in zip(a, b):
    c.append(x)
    c.append(y)

print (c)

output:

['a', '1', 'b', '2', 'c', '3']

Of course you can change it to match your needs, if needed

Samer Aamar
  • 1,298
  • 1
  • 15
  • 23