1

Basically, I am writing a keyboard practice game where you need to press specific keys to win. At the end, the player inputs their name (for a scoreboard) using input() function.

import keyboard

...
print(key_that_needs_to_be_pressed)
keyboard.wait(key)
if keyboard.is_pressed(key):
    ...

print('Game Over\nScore= ' + str(score))
user=input('Player:')
with open('scores.txt', 'a') as f:
    f.write(user+': ' + str(correct) + ' points\n')

And the output is:

r
t
space
f
d
b
d
w
Game Over
Score= 8
Player: rt fdbdw

Is there any way to get rid of the rt fdbdw part when the user needs to enter his name I tried using os.system('cls') and simulating pressing backspace before input() part but none of that works.

Edit:

I've tried flushing the input stream like this but that doesn't work. Other suggestion was this but I use windows.

wicked
  • 11
  • 2

0 Answers0