Created
March 3, 2019 12:05
-
-
Save Sean-Bradley/cbb4316bff54edd9f3cb103ffc1bad6b to your computer and use it in GitHub Desktop.
python print a number with padded zeros, using % rather than .format
This file contains hidden or 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
iNum = 123 #will always be a number | |
sPaddingChar = "0" | |
iNumPads = 6 | |
#print the number with padded zeros, using % rather than .format | |
print ('%s' % (str(iNum).rjust(iNumPads, sPaddingChar))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment