- zfill() is a python in-build function which add zero at the starting of the string.
Syntax-
str.zfill(width)
- here str is the given string.
- and width is the final length of the string.
Example
string is s="mytext"
s.zfill(10) will give "0000mytext"
string is s="mytext"
s.zfill(8) will give "00mytext"
program-
s="mytext"
print(s.zfill(8))
print(s.zfill(10))
print(s.zfill(12))
print(s.zfill(15))
print(s.zfill(20))
print(s.zfill(24))
print(s.zfill(28))
00mytext
0000mytext
000000mytext
000000000mytext
00000000000000mytext
000000000000000000mytext
0000000000000000000000mytext