Say I wanted to display the number 123 with a variable number of padded zeroes on the front.
For example, if I wanted to display it in 5 digits I would have digits =
Use string formatting
print '%(#)03d' % {'#': 2} 002 print '%(#)06d' % {'#': 123} 000123
More info here: link text