Created
November 17, 2024 08:47
-
-
Save James-Ansley/83c82a8bb6582f8fec5118318e28e004 to your computer and use it in GitHub Desktop.
This file contains hidden or 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