0 votes
1 view
in Python by (47.8k points)

I want my script to wait until the user presses any key.

How do I do that?

1 Answer

0 votes
by (107k points)

If you are using Python 3 version then you can use the following syntax to make a wait key:-

input("Press Enter to continue...")

If you are using Python 2, you should use raw_input(), as input(prompt) is equivalent to eval(raw_input(prompt)):

raw_input("Press Enter to continue...")

All these methods only wait for a user to press the enter button, so you might want to use msvcrt which works in Windows/DOS only. The msvcrt module gives you access to a number of functions in the Microsoft Visual C/C++ Runtime Library (MSVCRT)):

import msvcrt as m

def wait():


So you can use it to make a program for a wait keypress.

If you wish to know what is python visit this python tutorial and python interview questions.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !