You can download this code by clicking the button below.
This code is now available for download.
This function takes a string and a width as arguments. It pads the string on the left with spaces until the string reaches the specified width.
Technology Stack : str.zfill(width)
Code Type : String fill function
Code Difficulty :
def zfill_string(s, width=0):
"""
Right-justify a string in a filled field of a given width. Padding is done on the left.
"""
return s.zfill(width)