[Tutor] What is wrong my code?
dyoo at hkn.eecs.berkeley.edu
Fri Mar 24 22:45:25 CET 2006
> leg1 = raw_input('Enter the first leg of the triangle:
> leg2 = raw_input('Enter the second leg of the
> triangle: ')
leg1 and leg2 here are strings, because raw_input() is guaranteed to
You'll want to do something to turn those strings into numbers, since the
> result = hypotenuse(leg1, leg2)
is going to break on non-numeric input.
I think you'll find the float() function useful: it's a function that can
take strings and return floating-point numbers. For example:
Good luck to you!
More information about the Tutor