Skip to content

Instantly share code, notes, and snippets.

@James-Ansley
Created November 17, 2024 08:47
"""
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