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 trial

Python Python Basics (2015) Logic in Python Try and Except

Stuck on Python Exceptions... help please!

Want to add an ValueError exception to the function add. I believe I have the correct format, yet I keep getting a can't convert an int error.

```def add(arg1,arg2): try: adding = arg1 + arg2 except ValueError: return None else: adding = float(arg1) + float(arg2) return adding

add(2,3)```

trial.py
def add(arg1,arg2):
    try:
        adding = arg1 + arg2

    except ValueError:
        return None

    else:
        adding = float(arg1) + float(arg2)
        return adding

It think you missed a point. From the challenge description the else block is supposed to return the result adding . It should work if you move/replace the addition line with float casting to the try block.

On the second part of the challenge, it has you convert your arguments to floats before adding them. It seems in your try block you have removed the floats. Your ValueError block is fine. All you are required to do in the else block is return your adding variable. Hope this helps! Reply if you have any more questions!

Thank you Bleza Takouda and Enzie Riddle ... I can see clearly now! Much appreciated.