0

Say if I did:

print("hello")
print("nice to meet you!)

What I wanted it to do output is:

  hello

then you press the enter key and then it does the print("nice to meet you!").

(I am making a subtitle story type thing.)

I tried input() but that allows text input when I only want I to allow the Enter key. I don't know if if could do a detect key pressed or something.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • 2
    Does this answer your question? [How do I make python wait for a pressed key?](https://stackoverflow.com/questions/983354/how-do-i-make-python-wait-for-a-pressed-key) – MLavrentyev Feb 18 '21 at 15:04
  • On Windows you can use [`msvcrt.kbhit()`](https://docs.python.org/3/library/msvcrt.html#msvcrt.kbhit) to check to see if a key has been pressed (and [`msvcrt.getch()`](https://docs.python.org/3/library/msvcrt.html#msvcrt.getch)) to read what key it is if it matters). – martineau Feb 18 '21 at 16:33

2 Answers2

0

You can try this, but the easiest way to use input() function. However, you can use this function for any keyboard input

import keyboard as keyboard
print("Hello")

while True:
    try:
        if keyboard.is_pressed('Enter'):
            print("Nice to Meet You")
            break
    except:
        break
Nott
  • 303
  • 1
  • 8
0

You should try doing same

print ('hello')
input('Input some value: ')
print('nice to meet you!')
Vibhor Gupta
  • 670
  • 7
  • 16