3

Well I have this code:

x = input('write something: ')
print("you wrote: ",x)

The result:

>>> write something: hello! #line 1
>>> you wrote: hello!       #line 2

But I'd like that line 2 was written where is line 1, I mean, overwrite line 1. I couldn't do that because input() "ends" when user presses Enter which causes a new line on the console (the automatic new line described in the title). Sorry if my English isn't good. Thanks!

zondo
  • 19,901
  • 8
  • 44
  • 83
Luis Danilo
  • 47
  • 1
  • 6
  • 3
    With some (definitely not all) consoles, you could write control codes that erase and overwrite the previous line, but this would be console/terminal specific. For detailed crosss-platform control of output, you need to use a cross-platform package or GUI framework, such as tkinter. – Terry Jan Reedy Apr 19 '16 at 01:38
  • Did you take a look at that? http://stackoverflow.com/questions/16489974/how-to-not-issue-a-new-line-in-python-3-when-entering-text-with-input seems like it's almost duplicate – Yotam Salmon Apr 19 '16 at 03:48
  • Possible duplicate of [Possible to get user input without inserting a new line?](https://stackoverflow.com/questions/7173850/possible-to-get-user-input-without-inserting-a-new-line) – Carlos Afonso Aug 10 '17 at 21:31

0 Answers0