To add the leading zeros to a python string, we can use the
Here is an example, that adds zeros to the left side of a numeric string
num = "5" print (num.zfill(4))
Similarly, you can also use the
rjust() method to add the leading zeros.
num = "7" print (num.rjust(4, '0'))