Skip to content

Instantly share code, notes, and snippets.

@source-nerd
Created October 23, 2019 20:44
Show Gist options
  • Save source-nerd/59431394a2d3708de406922faab2e9b7 to your computer and use it in GitHub Desktop.
Save source-nerd/59431394a2d3708de406922faab2e9b7 to your computer and use it in GitHub Desktop.
# 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