0

I have two variables

odds=[1,3,5]
evens=[2,4,6]

and i want to print them in a loop like this:

for i in range(0,2):
  print(odds[i])
  print(evens[i])

to get an output like

1,2,3,4,5,6.

However the above loop doesn't feel very pythonic. Is there way of doing this more pythonicly? perhaps with a loop thats defined via a line like "for odd in odd and for even in even:"?

Abijah
  • 512
  • 4
  • 17

1 Answers1

0
for x,y in zip(odds,evens):
    print(x,",",y)
user27286
  • 486
  • 4
  • 11