How do I get user input to refer to a variable in Python?
- by somefreakingguy
I would like to get user input to refer to some list in my code. I think it's called namespace? So, what would I have to do to this code for me to print whatever the user inputs, supposing they input 'list1' or 'list2'?
list1 = ['cat', 'dog', 'juice']
list2 = ['skunk', 'bats', 'pogo stick']
x = raw_input('which list would you like me to print?')
I plan to have many such lists, so a series of if...then statements seems unruly.