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 trialhu sile
Courses Plus Student 1,719 PointsGot stuck at this Python basics code challenge. I think my codes are right, but it says that task 1 or 2 is not right!
def add(x, y): return x + y
def add(x, y): a = float(x) b = float(y) return a + b
def add(x, y):
try:
a = float(x)
b = float(y)
except ValueError:
return None
else:
return True
def add(x, y):
return x + y
def add(x, y):
a = float(x)
b = float(y)
return a + b
def add(x, y):
try:
a = float(x)
b = float(y)
except ValueError:
return None
else:
return True
1 Answer
Brett McGregor
Courses Plus Student 1,903 PointsHi Hu,
Notice that you have defined the add function three times. I think the question intends for you to modify the add function at each step rather than create a duplicate.
So, if you remove the first two add function definitions you can focus on all of the code challenge requirements in a single function definition.
Don't forget to return the two numbers added
Hope this helps you!