I am trying to loop similar variable names with different values but found unable to do so. I attached the code below. Could you advise me as to what to do by looping in order to get the effect of version 1 code? Many thanks.
#Version 1: The intended effect
def test():
global v1, v2, v3
v1 = 1
v2 = 2
v3 = 3
print (v1)
print (v2)
print (v3)
if __name__ == "__main__":
test()
And:
#Version 2: The loop I tried but failed
def test():
global v1, v2, v3
for i in range (1,3):
"v" + str(i) = i
print ("v" + str(i))
if __name__ == "__main__":
test()