Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialmarinmirosevic
3,279 Pointsreturn, except
can you help with code. what is wrong here
def add(here, there):
add (10, 10)
try:
int(add)
except ValueError:
return('None')
else:
return(float(here)+float(there))
2 Answers
Jeremiah Bushau
24,061 Pointshello, in the challenge he asks us to convert the two arguments to floats inside the try block before adding them together. Also, the indentation for except should match try and else. Here is one way to do it.
def add(a, b):
try:
a = float(a)
b = float(b)
except ValueError:
return None
else:
return a + b
marinmirosevic
3,279 PointsThank Jeremiah :) it worked