String Padding with `zfill()`

  • Share this:

Code introduction


The `zfill()` function is used to pad a string with zeros on the left until the string reaches the specified length. If the length is not specified, it defaults to 0.


Technology Stack : String

Code Type : String Handling Function

Code Difficulty :


                
                    
def zfill(arg1, arg2=0):
    return str(arg1).zfill(arg2)                
              
Tags: