I am a novice Python programmer and I have recently met a problem I can't find a way to deal with. The thing is, I have one list with elements and one variable with name of this list in form of string. It looks like this (I use python 3.7):
my_list = ['a', 'b', 'c', 'd']
var1 = 'my_list'
And my objective is to iterate through this list using for loop without using name of this list in command, only the variable's value (which is list's name). I tried to simply use var1 as the list itself, but, of course, it did not work out:
my_list = ['a', 'b', 'c', 'd']
var1 = 'my_list'
for item in var1:
print(item)
Is there a way to sort this out somehow?