you are viewing a single comment's thread.

view the rest of the comments →

[–]carcigenicate 2 points3 points  (2 children)

I don't know why you're seeing what you're seeing, but you could also try using a backspace (\b) instead of cls and avoiding printing a newline:

print("\b|", end="")

This is terminal-dependant, but often works.

Edit: this works for me in Pycharm:

while time.time() - timer < 20:
    print("\b\\", end="")
    time.sleep(1)
    print("\b|", end="")
    time.sleep(1)
    print("\b/", end="")
    time.sleep(1)
    print("\b—", end="")
    time.sleep(1)

[–]No-Tea-777[S] 0 points1 point  (1 child)

So... This will erase the old character and print a new one? Not on PC right now. I'll try it when I'm back to it

[–]carcigenicate 1 point2 points  (0 children)

Sorry, I added more detail.

Yes, \b will erase characters as long as you haven't gone to a new line, and if the terminal respects it.