If I have pre-set list variables that are the same name except for they end in a different number, how can I create variables in a for loop that will call those lists?
My issue is that the variable I create in the for loop is staying as a string. I need it to recognize that it's simply a name of a variable.
Example:
list1 = [2, 4, 3, 7]
list2 = [4, 5, 6]
list3 = [9, 5, 7, 8, 3, 2, 1]
list4 = [4, 1]
for i in range(1,5):
print ("list%d" % (i))
This results in printing the strings:
list1
list2
list3
list4
I want it to print out the actual lists.
Thanks for any help!