Python zfill Function Overview

  • Share this:

Code introduction


The function uses the built-in string method zfill to convert a number to a string and pad it with zeros on the left until the string length reaches the specified arg2 length.


Technology Stack : String, zfill

Code Type : String Handling Function

Code Difficulty : Intermediate


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