String Padding with zfill Function

  • Share this:

Code introduction


The zfill function is used to pad a string to a specified width, with 0 as the default width. If the string is shorter than the specified width, 0 is padded to the left of the string.


Technology Stack : str.zfill(width)

Code Type : String Handling Function

Code Difficulty :


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