Let's say I have a for
loop till the range(50)
and in that for
loop I want to create 50 variable names like v1
, v2
, v3
, v4
till v50
and the value of those variables should be the number which is in range, so v1
will be 0, v2 = 1
, and v50 = 49
.
I tried this way but it failed:
for i in range(50):
v{i} = i
print(globals()) # We print all the variables