[Tutor] printing 00
Shantanoo Mahajan
shantanoo at gmail.com
Tue Jul 11 14:29:17 CEST 2006
+++ Christopher Spears [10-07-06 21:34 -0700]:
| 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
instead of %d you may use %02d.
Shantanoo
--
It's not what you look at that matters, it's what you see. ~Henry David
Thoreau
More information about the Tutor
mailing list