my_str='plus2net'
output=my_str.zfill(15)
print(output)
my_str='25'
output=my_str.zfill(5)
print(output)
output is here
0000000plus2net
00025
id=str(45) #convert to string
print(id.zfill(5)) # 00045
It works only with strings, so integers must be converted to strings before using zfill(). This is helpful when handling numerical IDs or fixed-length formats.my_str = '25'
output = my_str.zfill(5)
print(output) # Output: '00025'
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.