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)
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)
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