There are a number of existing posts on this topic, but I cannot get this simple piece of code to work correctly. I have tried many many times with no success...
per = 5
if per < 10 == True:
ms = 'fwd_%sd' % str(per).zfill(2)
else:
ms = 'fwd_%sd' % per
and
if per < 10 == True:
a = format(per, 'fwd_02d')
else:
a = 'fwd_%sd' % per
The result should be 'fwd_05d' but I can only get 'fwd_5d'.
Among others, I have seen:
Display number with leading zeros
Please help!