1

so i want to output '|' and the remove it and paste '/' instead (in one line) so it will make animation.

import time


animation = '|'
print(animation)

time.sleep(0.5)

animation = animation.replace('|', '/')
print(animation)
2

1 Answer 1

0

In a nutshell, you need to output \r character, which is a carriage RETURN command. It will put the caret to the start of the line in the console. Next output will basically rewrite the line contents.

import sys, time

i = 0
while True:
    sys.stdout.write('/-\\|'[i%4])
    time.sleep(0.5)
    sys.stdout.write('\r')
    i += 1
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.