Python - String Method - zfill() Tutorial
The zfill() method will fill the string with '0' from the left until the length of the string reaches the specified length.
Syntax-
String.zfill(width)
#width- It will fill the string with '0' from left until the
whole string including '0' will reach the length of the
specified width
Example-
str1 = "Hello Sam"
print(str1.zfill(10))
print(str1.zfill(15))
print(str1.zfill(5))
Output-
0Hello Sam
000000Hello Sam
Hello Sam