print str(1).zfill(3); # Expected output: 001 # Since python 3.6 you can use fstring : number = 1 string_to_print = f"padded number: {number:05}" print(string_to_print) >>> padded number: 00001