I have the following function
def reproducir(texto):
pygame.mixer.music.load(TECLADO)
for letra in str(texto):
pygame.mixer.music.play()
print(letra, end="")
time.sleep(0.05)
sys.stdout.flush()
pygame.mixer.music.stop()
As you can see the function prints letter by letter the text with a background sound.
If I press enter while the letters are printed, it generates a line break and distorts the msj.
If you press any other letter, it prints on the screen and distorts the msj.
How can I prevent this from happening?