Welcome to the Treehouse Community
Looking to learn something new?
Functions: Float, Try, Except and Else
I followed step by step to my abilities, I think there should something else after the try block but I'm not certain what I'm doing wrong!
def add(whats, up): try: except ValueError return None else: return float(whats) + float(up)
Elad Ohana24,456 Points
You're very close. The only thing that you have to change is the order of things. As written, your code asks to try something, but then doesn't state what to try. You can change your code to
return float(whats) + float(up) and if it fails,
return None. Since you are converting your variables and returning the value at the same time, there isn't really a need for an
else, as your
try statement already performs all the functionality required in the challenge.
Take a look and good luck!