Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Maryan Tuzyak1,495 Points
converting the arguments into floats
i have tried converting the top arguments into floats but not sure if doing it properly i'm assuming converting arguments to floats before adding them ,tried float() to total and add keeps telling me error in line 1
def add float((n1,n2)): return(n1+n2) total = add(2,8) print(total)
Kent Åsvang18,822 Points
You can't convert the argument-list - instead you should consider to convert the numbers inside your function. This is how I would do it:
def add(a, b): return float(a+b) # but you could also do something like this for clarity: def add(a, b): a = float(a) b = float(b) sum = a + b return sum
Hope this helped.