python - For loop iterating through list of variables -


i looking way for loop able iterate through list of variables , able use them variables this:

>>> = "original" >>> b = "original" >>> c = "original" >>> d = "original" >>> in [a,b,c,d]:         = "change" >>> print(a,b,c,d) change change change change 

your initial code not work because setting value of "i" not set value of variables "a", "b", etc.

a = "original" b = "original" c = "original" d = "original" list = [a,b,c,d] in range(0,len(list)):     list[i] = "change" print(list) 

Comments