[python] How to make a script wait for a pressed key?

I want my script to wait until the user presses any key.
How do I do that?

This question is related to python wait keyboard-input

The answer is

In Python 3 use input():

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

In Python 2 use raw_input():

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

This only waits for the user to press enter though.

One might want to use msvcrt ((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():

This should wait for a key press.

Additional info:

in Python 3 raw_input() does not exist

In Python 2 input(prompt) is equivalent to eval(raw_input(prompt))

Similar questions with python tag:

Similar questions with wait tag:

Similar questions with keyboard-input tag: