Newbie! I'm a newbie! What's wrong with this program?
Erik Max Francis
max at alcyone.com
Sat Jul 19 22:19:44 EDT 2003
Id0x wrote:
> ##Function for converting minutes to hours##
> def minHour(x):
> min = 60
> hour = min * x
> print hour
Your function does the conversion and then _prints_ the result. It
doesn't return anything.
> print "There are", minHour(x_hours), "minutes in", x_hours, "hours";
Here you're trying to print the return value of minHour, which since you
didn't return anything, defaults to None. Fix it by making that last
line of minHour
return hour
instead of
print hour
> newLine();
> print "Program Terminated.";
> newLine();
Note that Python does not require an end of line discriminator, so all
these semicolons are redundant (you seem to know this since since you
don't use them in some places, but use them in others). (Also,
"newLine()" really is a curious abbreviation for "print" :-).
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Love is a hole in the heart.
\__/ Ben Hecht
More information about the Python-list
mailing list