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!
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 trial
Yann Husseini679 Points
I am stuck in this challenge.
Can someone tell me where is my error?
try: def add(arg1, arg2): return(float(arg1) + float(arg2)) except ValueError: return None add(9, 8)
Jon Mirow9,864 Points
try is outside the function definition. Remember that functions don't do anything until you call them by putting () on the end. So this says to python try defining a function... which doesn't make sense to python. Moreover you get a conflict - the block that follows try needs to be indented, and the code inside the function needs to be indented, but the except needs to line up with the try and be inside the function... so it's all too much for python and you get an error.
The fix: just move the try inside the function.
Hope it helps :)
this one worked for me:
def add(arg1, arg2): try: return(float(arg1) + float(arg2)) except ValueError: return None
just but the 'try' statement inside your function - like Jon said ;)