format
zfill
ljust
Pads the string on the left with zeros to fill the given width.
str.zfill(width)
Enter values below to update the example in real time.
code
print
code = "42" print(code.zfill(5)) # 00042 print(code.zfill(2)) # 42