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 trialDaniel Holmes
2,765 Pointsneed help
def add(x, y): # number 1 and 2 return x + y # number 3
def add(num1, num2): try: a = float(num1) # <-- indent b = float(num2) # <-- indent except ValueError: return None else: return(a + b)
def add(num1, num2): try: a = float(num1) # <-- indent b = float(num2) # <-- indent except ValueError: return None else: return(a + b)
I need help the third part does not work and have been dealing with this for about a week
def add(x, y): # number 1 and 2
return x + y # number 3
def add(num1, num2):
try:
a = float(num1) # <-- indent
b = float(num2) # <-- indent
except ValueError:
return None
else:
return(a + b)
def add(num1, num2):
try:
a = float(num1) # <-- indent
b = float(num2) # <-- indent
except ValueError:
return None
else:
return(a + b)
1 Answer
Kourosh Raeen
23,733 PointsYour code for part 3 looks good. I just tried it and it passed. Make sure you don't have all the code you posted above in the trial.py file. You should have only this:
def add(num1, num2):
try:
a = float(num1) # <-- indent
b = float(num2) # <-- indent
except ValueError:
return None
else:
return(a + b)
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsLooks like the last
def
statement is indented too far.