Str zfill pads a string in python with zeros on left side and returns string with specified width.
Syntax of Str.zfill:
str.zfill(width)=>String
a='God is great'
a is string with length 12
a.zfill(15) Output: '000GOd is great'
It will return output of length 15 as specified width is 15 in zfill(15) method.As you can see in image above length of string is 12 and after applying zfill it had prefixed 3 zero’s in string a.
[…] 39.Str.zfill:It pads a string with zero on left side, to return a string of specified width. […]