Skip to content Skip to sidebar Skip to footer

How To Enter A Input Without Pressing Enter

For instance I would like it so, x = int(input('Please enter your guess :') If x = 1: Print ('correct') Although each time i need to press enter, how could I make it so it woul

Solution 1:

In Windows you can use msvcrt. On other systems its a bit more difficult, take a look at this recipe: http://code.activestate.com/recipes/134892/

You can use it that way:

getch = _Getch()

print'Please enter your guess: '
x = getch()

if (int(x) == 1):
    print'correct'else:
    print'wrong'

Post a Comment for "How To Enter A Input Without Pressing Enter"