0

I'm new to the world of python and the world of programming in general and i'm coding a programm. I would like figure out how to create a different global variable for each for() output. I searched something on Youtube, there and on the official site of Python but nothing.

var = (1,2,3,4)
for element in var:
    x_1 = 1
    x_2 = 2
    x_3 = 3
    x_4 = 3

1 Answers1

0

The short and sweet:

x_1, x_2, x_3, x_4 = var

What is happening is you are matching each variable to each number inside of var, this will work if you assign the correct number of variables on the left as there are on the right.

William Bright
  • 535
  • 3
  • 7