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

I really don't get how I can get the float function to work with two arguments!

Hi there,

My code looks like this:

def add(num1, num2): return (num1+num2)

add(float(1.5,3.2)

Can someone help me?

Cheers, SimWolf

trial.py
def add(num1, num2):
    return (num1+num2)

add( float(1.5,3.2)

1 Answer

Brett McGregor
PLUS
Brett McGregor
Courses Plus Student 1,903 Points

Hi Jamie,

In this code challenge, you don't need to call the function i.e your last line of code

So, with that in mind, you'll need to use the float() function to convert the two arguments/numbers to float before you add them together within the function definition.

A small clue, but hope it gets you across the line on this one!

Hey Brett,

Thanks for this! I'm not sure I follow, I've removed the call at the end. Do I need to add the float inside the function in the sense that I convert num1 and num2 to floats, then return adding them together?