Created
November 17, 2024 08:47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Thought this was cute. | |
""" | |
import time | |
PARTS = ("", "▏", "▎", "▍", "▌", "▋", "▊", "▉") | |
BLOCK = "█" | |
def bar(count, total, width): | |
pct = 100 * count / total | |
normalised = round(pct / 100 * 8 * width) | |
bar = BLOCK * (normalised // 8) + PARTS[normalised % 8] | |
return f"[{bar:<{width}}] ({pct:.0f}%)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment