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 trialAmr AbdelNasser
1,745 Pointsfunctions and exceptions
can't seem to pass the challenge without getting that Task 1 is on longer passing. I tried the code in workspace and it works, wondering what i missed from the challenge objective.
def add(e,r):
try:
e= 3
r= 4
except VlaueError:
return None
else:
return float(e)+float(r)
3 Answers
Khaleel Yusuf
15,208 PointsYou spelt ValueError incorrectly.
Khaleel Yusuf
15,208 PointsMaybe you could give me Best Answer?
Nicholas Tapps
426 PointsIt took me about 20 minutes to get this down, but I finally got it:
Your "try" block doesn't actually have a code to test, it just has the integers for the arguments. The code I used for try was: add=float(x)+float(y)
The "None" in your except block needs to be in parenthesis, such as: return (None)
And the remainder of your function (minus the "add(3, 4)" that should have been present in all three challenges) should be under the "else" block (indented of course): else: e=float(e) r=float(r) return(e+r)
add(3, 4)
I hope this helps!
Amr AbdelNasser
1,745 PointsAmr AbdelNasser
1,745 Pointsthanks, must have been a typo but I'm still getting the same output of "Task 1 no longer passing"