'How To Update a Line Without Printing a new One in Python? [duplicate]

I am trying to make a progress bar, but I don't want it to print a new line for each character that represents the bar (like: "#"). How do I update the line without printing it again?



Solution 1:[1]

This is not direct answer to question but just potential suggestion. for many "pretty" terminal formatting i have found rich python package to be very useful. for example has progress bar: link see example of what looks like in gif under progress bar section of readme

Solution 2:[2]

You need to change the end of line character to nothing.

print("#", end =''', flush=True )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kamster
Solution 2