String Padding with Leading Zeros

  • Share this:

Code introduction


Returns a string filled with zeros on the left side until its length reaches the specified width.


Technology Stack : str.zfill(width)

Code Type : String processing

Code Difficulty :


                
                    
def zfill(string, width=1):
    return string.zfill(width)