[Tutor] Is this correct?

Kent Johnson kent37 at tds.net
Sun Apr 16 13:30:16 CEST 2006


Hoffmann wrote:
> So, I wrote the script below:
> 
> class Time:
> 	pass
> 	
> hour = int( raw_input('Enter the hour: ') )
> min = int( raw_input('Enter the minute: ') )
> sec = int( raw_input('Enter the sec: ') )
> 
> time = Time()
> time.hours = hour
> time.minutes = min
> time.seconds = sec
> 
> def printTime(time):
> 	print 'The time is %dh:%dmin:%dsec' % (hour, min,
> sec)

You fixed this in your later version, but here you are not using the 
hour, min, sec attributes from time, you are using the global hour, min, 
sec from the raw_input() calls. It should be time.hour, etc.

Kent



More information about the Tutor mailing list