I wanted to convert 55 to 0055, similarly 655 to 0655 (so I can parse it with dateutil.parser).
I could do an if len == 2 add 00 + len == 3 add 0 statement, but I wonder if there’s a cleaner approach (e.g regex).
Any advice or help is much appreciated!
>Solution :
zfill should do it, if you have ints to begin with and want to end with string for instance:
str(55).zfill(4)