I'm trying to make a loading progress bar, but I get something like this when I run my code:
[ ] 0%
[= ] 10%
[== ] 20%
[=== ] 30%
[==== ] 40%
[===== ] 50%
[====== ] 60%
[======= ] 70%
[======== ] 80%
[========= ] 90%
[==========] 100%
When I expected something like this:
[ ] 0%
<Later>
[= ] 10%
<Even Later>
[== ] 20%
<And you get the idea>
It's supposed to clear the previous line every time it prints a new one. I've tried everything I found on Google, but it wasn't much help. I tried using "\r", but I get this:
[ ] 0%
[= ] 10%
[== ] 20%
[=== ] 30%
[==== ] 40%
[===== ] 50%
[====== ] 60%
[======= ] 70%
[======== ] 80%
[========= ] 90%
[==========] 100%
Here's my code:
import time
import random
for p in range(0, 11):
print("[" + ("="*p) + (" "*(10-p)) + "] " + str(p*10)+"%")
time.sleep(random.uniform(0.1, 1))
Can someone help find a way to clear the whole output console?