1

I was wondering if something akin to:

x,y = (1,2),'a'

would be possible in a for loop, like:

my_tuple = ((1,2),(2,3),(3,4))
your_tuple = ('a','b','c')

for x,y in my_tuple, your_tuple:
    ...

At the moment I can't even figure out how to do it with 3 variables.

1 Answers1

0

You can use zip, my dear friend! Here is the code:

my_tuple = ((1, 2), (2, 3), (3, 4))
your_tuple = ('a', 'b', 'c')

for x, y in zip(my_tuple, your_tuple):
    print(x, y)
Mark White
  • 640
  • 1
  • 5
  • 12