Created
November 7, 2018 14:53
-
-
Save Da-Juan/cf805d1ef8bfc59c6dd211b9fcfe1b1e to your computer and use it in GitHub Desktop.
Write growing percentage on standard output
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
#!/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