I am quite new to Python programming, just started about a week ago, and was just designing a simple menu for a simple guessing game.

I have browsed Google and other websites trying to find snippets of code that may help me but my searches haven't turned up anything.

I've got it displaying the menu correctly;

"(P)lay game

but I am having trouble working out how to get the user input, such as when they push 'i' it displays the instructions for the game and when they push 'p' it starts the game.

If anyone could lead me down the right path it would be greatly appreciated, back to trying to work it out in the mean time.

5 Years
Discussion Span
Last Post by Atistus

I don't think there is a module or package providing key press event functionality for the console.

If you want user input, you should use the function raw_input in 2.x and input in 3.x.


OP do not necessary need more than input (raw_input in Python 2) Also there should be one Vegaseats snippet how to use Tkinter without window to get key event. You could also adapt the Tkinter menu I have posted before, it is not finally so much more difficult than writing text based app.


if its in console, Then you just get the user input and check the value.
Then instruct your system based on that choice.

This question has already been answered. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.