Skip to content

Instantly share code, notes, and snippets.

@Da-Juan
Created November 7, 2018 14:53
Show Gist options
  • Save Da-Juan/cf805d1ef8bfc59c6dd211b9fcfe1b1e to your computer and use it in GitHub Desktop.
Save Da-Juan/cf805d1ef8bfc59c6dd211b9fcfe1b1e to your computer and use it in GitHub Desktop.
Write growing percentage on standard output
#!/usr/bin/env python3
"""Percentage output."""
count = 0
items_nb = 500000
while True:
# You can replace .0f by .2f to output decimals
print(f'{count * 100 / items_nb:.0f}%', end='\r')
count += 1
if count == items_nb:
print('')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment