Ask coding questions

← Back to all posts
How to pervent it printing S?
PhoenixFoxx (0)

When I run this, it automatically prints S. How does one fix this?

Answered by themining72 (49) [earned 5 cycles]
View Answer
themining72 (49)

Remove line 6 and change line 8 to:

input1 = input('Type S to get started!')

input() requires you to put in the question, not what you want the player to type.

PhoenixFoxx (0)

@themining72 ok, but now how do i make it so you have to type 'S'? enter progresses it now, witch isnt an issue now, but it will be in the futre when i go to make the controls and stuff

themining72 (49)

@PhoenixFoxx Well, there is no simple or built in way to do this, but i can still provide you with a long answer if you want.

themining72 (49)


def getch():
  import sys, tty, termios
  fd = sys.stdin.fileno()
  old = termios.tcgetattr(fd)
    termios.tcsetattr(fd, termios.TCSADRAIN, old)

while True:
  if getch() == "S" or getch() == "s":

Replace input1 = input('Type S to get started!') with the above.

PhoenixFoxx (0)


my brain now hurts, but i think i can figure it out... maybe... thank you very much!