0

I want python to take in input then print out the input with added characters in front without outputting the original input.

Example:

foo = input("")
print("Me: " + foo)

should output

Me: foo

instead of

foo
Me: foo

I can't just do input("Foo: ") as there are other threads outputting to the console and they mess up the formatting.

  • 1
    Try using the getpass library. As answered already here: https://stackoverflow.com/questions/4616813/can-i-get-console-input-without-echo-in-python – RandoGuy Aug 17 '20 at 02:31
  • Does this answer your question? [Can i get console input without echo in python?](https://stackoverflow.com/questions/4616813/can-i-get-console-input-without-echo-in-python) – jkr Aug 17 '20 at 03:17

1 Answers1

0

You can use a Erase Line string to clear the line above:

foo = input("")
print("\033[2K\033[1AMe: " + foo)

This clears the foo As well as the newline

Me: foo
hedy
  • 1,160
  • 5
  • 23