Hi everyone,
Forgive me if the title is not lucid, but I could not better describe it in a single sentence.
Consider I have the following in a loop, which increments counter
each time it runs.
output_string = 'Enter the number [{0}]'.format(counter)
When I do a print output_string
, the output goes like:
Enter the number [1]:
When I print this line again with the incremented number, like:
Enter the number [2]:
It will of course follow the 1st line and the cumulative output would be:
Enter the number [1]:
Enter the number [2]:
However, I don't want this. I want the first line line should be updated and without adding another line, the output should just change in the first line itself.
Like, it should display Enter the number [1]:
and after that it should do an in-place replacement for [1] and the screen should read: Enter the number [2]
, without adding an extra line.
I hope I am being clear. The reason I am doing this is because I am taking in large inputs from the user and I don't want to clutter up the terminal when I can just keep on incrementing what I want within a single line.