PythonStringzfill

Pads the string on the left with zeros to fill the given width.

Syntax

str.zfill(width)

Example

Enter values below to update the example in real time.

code
print
zfill
code = "42"
print(code.zfill(5))   # 00042
print(code.zfill(2))   # 42