Python readline delete the printed content line on double clicking backspace

134 Views Asked by At

I have a simple python code where i printed a question and i expect input from the user. I imported readline so that user can access to history of his inputs and use arrow keys. This is the code :

import readline

print("Welcome to Numgame, please enter a number \nuser $", end=" ")
m = input()

After running the script, if i add one character and press backspace to remove the character all of the second line is deleted.

Example: This is the output of running the script and typing for example 'e' :

Welcome to Numgame, please enter a number

user $ e

If i press backspace, the output looks like this:

Welcome to Numgame, please enter a number

As you can see, the second line is gone. I want a solution so that i can use backspace without "user $" being removed.

0

There are 0 best solutions below