So I am dealing with zip codes and when the zip code starts with 0, excel does not keep and when I import into arcmap, I therefore have issues joining to other shapefiles with a zip-code field. I am trying to write a script that will automate this process and calculate a new field to ensure that all zip codes have 5 digits but I cant get it to work. Attached is what I have written in python, essentially to determine the length of the zip code, and if it is complete (5digits) just make I a string and if it is not, to concatenate the necessary number of 0s to make it 5 digits.
Just looking at your expression, and not addressing the script, what you want can be easily accomplishing using Python string formatting:
Also, this will get more visibility if posted in https://community.esri.com/community/developers/gis-developers/python?sr=search&searchId=f40150fc-75....
Then there is the blogs on Basic Fancy Formatting... with references to Fancy Fancy Formatting and a variety of other tips. You can waste a whole day making stuff look nice without getting any meaningful work done... all the tips are there