(Nov-18-2017, 01:35 PM)buran Wrote:my_switch = {'1':foo, '2':bar} while True: user_input = input('Select function to execute (1 for foo, 2 for bar): ' )
I would even go as far to have the options be calculated from the dictionary, so if you change the dict, the question will automatically mention the new function as an option as well, and you don't have to think about changing two places.