Skip to content

Instantly share code, notes, and snippets.

@brettvitaz
Created February 17, 2023 22:06
Show Gist options
  • Save brettvitaz/97953b461e18087f1d37598561c36aec to your computer and use it in GitHub Desktop.
Save brettvitaz/97953b461e18087f1d37598561c36aec to your computer and use it in GitHub Desktop.
Simple console progress bar with no dependencies
def print_progress_bar(iteration, total, prefix='', suffix='', decimals=1, length=100, fill='█', print_end=""):
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
filled_length = int(length * iteration // total)
bar = fill * filled_length + '-' * (length - filled_length)
print(f'\r{prefix} |{bar}| {percent}% {suffix}', end=print_end)
# Print New Line on Complete
if iteration == total:
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment