0

I'm writing code which requires different types of user input and I want the user to see what to write where but I want the information I'm giving to disappear as soon as the user starts typing for example:

question = "insert number here"
xa = float(input(f"xa ={question} "))

How do I make the question variable disappear when the user starts typing a number?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
omeir2404
  • 3
  • 2
  • What platform are you writing for? For example, if you're using tkinter, try this: [How to insert a temporary text in a tkinter Entry widget?](https://stackoverflow.com/q/30491721/4518341) – wjandrea Mar 15 '21 at 19:11
  • BTW, welcome to Stack Overflow! Check out the [tour] and [ask]. – wjandrea Mar 15 '21 at 19:12
  • What is your basic code, which doesn't show the input information yet? – pts Mar 15 '21 at 19:13

1 Answers1

0

i'm came cross with this solution

pip install pynput

from pynput.keyboard import Listener

question = "insert number here"

def on_press(key):
    print ("\033[A                             \033[A")

    xa = float(input())
    print (f"xa = {xa}")
    return False

with Listener(on_press=on_press) as listener:
    print(f"xa ={question} ")
    listener.join()

it's going to clear last one line in python output (.e.g your question) when user start typing

kzlca
  • 391
  • 1
  • 6
  • hi i did what you said and it shows me: unresolved import 'pynput.keyboard' – omeir2404 Mar 15 '21 at 21:20
  • this is another issue, i guess you are using vscode, if you are, check this [link](https://stackoverflow.com/questions/53939751/pylint-unresolved-import-error-in-visual-studio-code) hope it's fix your issue – kzlca Mar 16 '21 at 04:17