Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Created September 18, 2019 14:13
Show Gist options
  • Save vlad-bezden/1c4cfbe5b570e002bcf918a9e3d5a224 to your computer and use it in GitHub Desktop.
Save vlad-bezden/1c4cfbe5b570e002bcf918a9e3d5a224 to your computer and use it in GitHub Desktop.
Progress bar implementation in Python
from time import sleep
def progress(percent=0, width=50):
left = width * percent // 100
right = width - left
print('\r[', '#' * left, ' ' * right, ']',
f' {percent:.0f}%',
sep='', end='', flush=True)
for i in range(101):
progress(i)
sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment