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
what is the correct syntax for try and except with two arguments that should return a float
Can someone take a look at my structure for this code challenge, I am not sure what is causing this challenge to fail.
def add(apple, orange): try: apple = int(input("please input a number")) orange = int(input("please input a number")) except ValueError: return None else: return float(apple) + float(orange)
Thanks I got it! I got messed up when I was trying to evaluate the arguments not the results. also to note that you do not need to declare a variable in the try block for the challenge to pass though it does make sense for dry purposes, the last expression in your block can be return final instead of repeating your expression.