Created
October 23, 2019 20:44
-
-
Save source-nerd/59431394a2d3708de406922faab2e9b7 to your computer and use it in GitHub Desktop.
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
# native Python progress bar without using any library | |
from time import sleep | |
def progress_bar(percent=0, width=30): | |
left = width * percent // 100 | |
right = width - left | |
print('\r[', '#' * left, ' ' *right, ']', f'{percent: .0f}%', sep='', end='', flush=True) | |
if __name__ == "__main__": | |
for i in range(101): | |
progress_bar(i) | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment