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

Derick Ho
Derick Ho
3,113 Points

how do I convert values to float?

I tried to do

num1 = float(arg1) num2 = float(arg2) return num1 + num2

but it wouldn't work

trial.py
def add(float arg1,float arg2):
    return arg1 + arg2

1 Answer

Steven Parker
Steven Parker
231,269 Points

When you say "it wouldn't work", had you already put the word "float" in with the arguments? That's not proper syntax.

Otherwise, it should work just fine.

Derick Ho
Derick Ho
3,113 Points

I fixed it already. Thanks a lot though.

Steven Parker
Steven Parker
231,269 Points

If a question has not been answered, you can always delete it. If it has been answered adequately, you can mark it solved by choosing a "best answer", and if no answer is adequate you can edit the title and add "[SOLVED]".