1
ent = input("Press the Enter key to spin the roulette wheel.")
if ent == "":
    print("Roulette wheel spinning...")
    print("Roulette wheel spinning...")
else:
    #I want it to do nothing till only enter is hit What can I write here?

Is there way so when a key other than enter alone is pressed that it wont do anything until only enter is pressed? Using input allows the users to write something and therefore when they hit enter it will always run through. I'd prefer it if I can disable the writing and only respond when the enter key is hit.

martineau
  • 99,260
  • 22
  • 139
  • 249
Cherry
  • 181
  • 2
  • 9
  • @Selcuk umm. It doesn't answer the question at all, you just do this for the points. – Ari Mar 01 '19 at 02:11
  • 1
    Cherry, have a look at https://stackoverflow.com/questions/13180941/how-to-kill-a-while-loop-with-a-keystroke – Ari Mar 01 '19 at 02:12
  • There are some OS-dependent ways to do it, for example on Windows you can use `msvcrt.getch()` and check the return value. – martineau Mar 01 '19 at 02:49
  • For UNIX, you may use `curses` as below. Please check this - https://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key/6037500#6037500 – Kondasamy Jayaraman Mar 01 '19 at 02:57
  • 1
    @AriVictor What points? – Selcuk Mar 01 '19 at 03:09
  • @martineau Those two duplicate questions did answer the question perfectly, I'd suggest you to re-read this question and the other answers. – Selcuk Mar 01 '19 at 03:10

1 Answers1

1

You could put a while loop around the input so until the input equals enter the user can't continue. For example:

while True:
    ent = input("Press the Enter key to spin the roulette wheel.")
    if ent == "":
        break
    print("Roulette wheel spinning...")
    print("Roulette wheel spinning...")

Hope this could help.

little_birdie
  • 4,389
  • 2
  • 21
  • 25
Eli.F
  • 26
  • 4