python - Appending leading zeroes to a given value -
this question has answer here:
- display number leading zeros 11 answers
i have various inputs below,i need make given digit 4 letter , append leading zeroes make 4 digit , add "00.00" @ front,can suggest how this?
input:- val = int(95) val = int(115) val = int(5) expected output:- 00.00.0095 00.00.0115 00.00.0005
you this, assuming 00.00 constant.
print(["00.00.{:>04d}".format(v) v in [95, 115, 5]]) # ['00.00.0095', '00.00.0115', '00.00.0005']
Comments
Post a Comment