Right-Justified String Padding

  • Share this:

Code introduction


Returns a new string which is the right justified version of the original string, padded with zeros on the left up to the specified length.


Technology Stack : str.zfill(int)

Code Type : String processing

Code Difficulty : Intermediate


                
                    
def zfill(arg1, arg2=0):
    """
    Returns a string which is the right justified version of the original string,
    padded with the specified number of characters on the left, default is 0.
    """
    return arg1.zfill(arg2)