Home >>Python String Methods >Python String zfill() Method
Python string zfill() method is used to add zeros (0) at the beginning of the given input string until it reaches the specified length. If the value of the length parameter is less than the length of the string then no filling of zeros is done.
Syntax:string.zfill(len)
Parameter | Description |
---|---|
len | This is a required parameter. It defines a number specifying the position of the element you want to remove. |
txt = "99"
x = txt.zfill(10)
print(x)
a = "hello"
b = "welcome to PHPTPOINT"
c = "10.000"
print(a.zfill(10))
print(b.zfill(10))
print(c.zfill(10))