Skip to content
Advertisement

How to make menu using dict evaluation for small python guessing game

JavaScript

So let’s say if user inputs 1 in menu screen, I want to call start_game() function, I know there is other way to do this but just interested in this particular way because I think its neat.

Advertisement

Answer

Don’t put strings in the dictionary, put references to the function.

JavaScript

Then you can do:

JavaScript

to execute the user’s choice.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement