On 17/02/12 01:29, Daryl V wrote:
def Int2Digit(integer):
if integer < 9:
strInteger = "0"+str(integer)
else:
strInteger = str(integer)
return strInteger
Or using format strings:
def int2Digit(integer):
return "%02d" % integer
Although this doesn't behave quite right for negative numbers.
But I suspect the function above's handling of negatives is not
strictly as intended either...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor