How can I use a variable name as the name of a list?
The first print statement gives a 1
, that's correct, but the last line gives a character m
because it is the first char of the string my_list
.
Instead, I want the first item from my_list
.
my_list = [1, 2, 3]
word = "my_list"
print(my_list[0]) # 1
print(word[0]) # "m"