Created
September 18, 2019 14:13
-
-
Save vlad-bezden/1c4cfbe5b570e002bcf918a9e3d5a224 to your computer and use it in GitHub Desktop.
Progress bar implementation in Python
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
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