'Anything like input() in Module Turtle?

Is there, in module Turtle, a function similar to input(), that stops the running of the code until ANY key is pressed?



Solution 1:[1]

Unfortunately there is not. But you can do this by msvcrt library.

You should first install msvcrt by

pip install msvc-runtime

then open your python editor, and write the following

import msvcrt
def wait():
     msvcrt.getch()

Note: This makes the program continue when you press enter and this only works in windows

Example:

import msvcrt as ms
def wait():
    ms.getch()

print("hi")
wait()
print("hello")
wait()
print("did it work")

this example program prints hi,

then waits the user to press enter,

than prints hello,

then waits for the user to press enter and finally it prints "did it work"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1