Zerofill use in Python

engrmahabub
Mahabubur Rahman
Published on Sep, 27 2023 1 min read 0 comments
image

Python zfill() method used for adding zero beginning of the string, until reaching the specified length. 

Syntax :

string.zfill(length) 
Here length paramitter is required. 

Example :  

y=str(30)
print(y.zfill(10))

Output:

0000000030

 

0 Comments