Skip to content

Instantly share code, notes, and snippets.

@ludndev
Created October 22, 2024 07:06
Show Gist options
  • Save ludndev/169292e333b711483404c2f382488122 to your computer and use it in GitHub Desktop.
Save ludndev/169292e333b711483404c2f382488122 to your computer and use it in GitHub Desktop.
def pretty_format(current: int, total: int):
total_str = str(total)
current_length = len(total_str)
current_str = str(current).zfill(current_length)
formatted_string = f"{current_str}/{total_str}"
return formatted_string
# xxample usage
print(pretty_format(1, 56)) # Output: 01/56
print(pretty_format(1, 120)) # Output: 001/120
print(pretty_format(34, 120)) # Output: 034/120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment