[Tutor] printing 00

Christopher Spears cspears2002 at yahoo.com
Tue Jul 11 06:34:23 CEST 2006


I'm working on a problem from "How To Think Like A
Computer Scientist".  I created  a Time class:

class Time:
	
	def __init__(self, hours, minutes, seconds):
		self.hours = hours
		self.minutes = minutes
		self.seconds = seconds

I created a function to print the Time object:

def printTime(time):
	print "%d:%d:%d" % (time.hours, time.minutes,
time.seconds)
		
However, when I type '00', I get the following:
>>> time = Time(12,34.4,00)
>>> printTime(time)
12:34:0
>>> time.seconds
0

How do I get around this problem?  I know there is a
time module.  However, I think that is overkill for
this particular assignment.



More information about the Tutor mailing list