String Padding with Zfill Function

  • Share this:

Code introduction


This function is used to fill the string to the specified length. If the length of the string is less than the specified length, it will be filled on the left with the specified character, the default being '0'.


Technology Stack : str.zfill(width)

Code Type : String formatting

Code Difficulty : Intermediate


                
                    
def zfill(arg1, arg2):
    """
    Return the string s filled to length width with the specified character (default is '0').
    """
    return arg1.zfill(arg2)