I have a list of objects. I have a user inputted string. I need to check and see if the string is in the list of objects.
For example:
string = "book"
object_list = [book, paper, pencil]
if eval(string) in object_list:
#do this, etc
This works as long as the string is in the list. If the string is something else, like: string = 'ruler'
Then the if eval(string)...
statement gives an error:
NameError: 'ruler' is undefined.