Hi, > The goal is to write a function printTime that takes a > Time object as an argument and prints it in the form > hours:minutes:seconds. > > 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
Personally I prefer to put the initialisation intomnan __init__() method, but otherwise it looks ok to me. Also I'd probably not use a class here but a simple tuple or similar, but your exercise seems to want an object and implies a class should be used. > def printTime(time): > print 'The time is %dh:%dmin:%dsec' % (hour, min, > sec) > > printTime(time) HTH, Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor