String Padding with Leading Zeros

  • Share this:

Code introduction


The zfill() method fills the string with leading zeros to the specified width.


Technology Stack : Built-in function

Code Type : String function

Code Difficulty : Intermediate


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