I want to create a python script that print loading with dots appearing 1 by 1 and disappering them 1 by 1. I know how to disappear all of them but I want them them to go back 1 by 1.
Here is the code:-
for x in range(5):
for y in range(4):
dot = "."*y
loading = (f"Loading {dot}")
print(loading + " ", end = '\r')
time.sleep(1)
>Solution :
I implemented the part that outputs dots in your code by making it a function.
import time
def dotmove(n):
dot = "."*n
loading = (f"Loading {dot}")
print(loading + " ", end = '\r')
time.sleep(1)
for x in range(5):
for y in range(4):
dotmove(y)
for z in range(2, 0, -1):
dotmove(z)