You can download this code by clicking the button below.
This code is now available for download.
Right-aligns the string within a field of a specified width, filling with the specified character, defaulting to spaces. If the specified width is negative, the string is left-aligned.
Technology Stack : String manipulation
Code Type : String operation
Code Difficulty : Intermediate
def zfill(string, width=0, fillchar=' '):
"""
Right-aligns the string in a field of a specified width, filling with zeros.
"""
return string.zfill(width)