I'm getting Arrow Key values in my Python Input using input()
.
This only happens during the time of execution of a Python Script. It doesn't happen if Input is taken from the Interpreter.
The Arrow Key values I'm referring to: Why does the terminal show "^[[A" "^[[B" "^[[C" "^[[D" when pressing the arrow keys in Ubuntu?
Contents of Script File:
s = input("Enter Something: ")
print(s)
Terminal Output:
$ python input_example.py
Enter Something: Now Pressing Left Arrow Key^[[D^[[D^[[D^[[D
Now Pressing Left Arrow Key
I'm unable to navigate (or say change cursor position) left or right while writing input cause the Arrow Key Values Show up in the Input. Is there any way to avoid them? In Terminal, generally, one can change the cursor position, this problem doesn't happen unlike Python's input()
.
P.s. I don't want to change any settings in bash cause I'm trying to write a script that works in all consoles. I'm a noob so I don't understand many things. I hope this community can help me out.