0
def walking():
Variable = True
while Variable == True: 
    print("Walking", end = "\r")
    time.sleep(0.5)
    print("Walking.", end = "\r")
    time.sleep(0.5)
    print("Walking..", end = "\r")
    time.sleep(0.5)
    print("Walking...", end = "\r")
    time.sleep(0.5)
    print("          ", end = "\r")

Im trying to get it to print out an animation that goes:

Walking delete it Walking. delete it Walking.. delete it Walking... then repeat

I don't want to delete everything on the console since other things are going to be shown when this is shown

  • If thats all you're doing it would be far easier just to print one extra dot on the same line – Sayse Apr 22 '22 at 08:26
  • 1
    or add `flush=True` to the print command ... read it up. – Patrick Artner Apr 22 '22 at 08:27
  • I have absolutely no idea how to do that, im still new to python – StinkingMerm Apr 22 '22 at 08:27
  • also: `while True: ............ break` – Patrick Artner Apr 22 '22 at 08:27
  • `print("Walking", end = "", flush=True)` sleep `print(".", end = "", flush=True)` sleep `print(".", end = "", flush=True)` sleep `print(".", end = "", flush=True)` sleep `print(".", end = "", flush=True)` ... no line deletion needed .. at the end overwrite with flush as well ... like [this answer](https://stackoverflow.com/a/3249539/7505395) proposes – Patrick Artner Apr 22 '22 at 08:28

0 Answers0