This is similar to what you are looking for:
Choose_Item = eval(input("Select your item: "))
This is probably not the best strategy, because a typo or a malicious user can easily crash your code, overload your system, or do any other unpleasant things that they like. In this particular case, the best approach might be
items = {'item1': 'bill', 'item2': 'cows', 'item3': 'abcdef'} choice = input("Select your item: ") if choice in items: the_choice = items[choice] else: print("Uh oh, I don't know about that item")
Dougal
source share