To fill in the first 0:
>>> print "'%06d'"%4
'000004'
This is what I know
'hi '
How do I add spaces back together? str+""*number
I know we can write together.
There is a way to write str.ljust(width[, fillchar]).
Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to len(s).
Returns a string of left-aligned width lengths. It is padded with fillchar, and the default value of fillchar is one space.
>>> 'hi'.ljust(10)
'hi '
© 2024 OneMinuteCode. All rights reserved.