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 trialGiacomo Melzi
3,095 PointsI really don't know what I'm doing wrong in this exercise. Please help :)
def add(pizza, pasta): float(pizza, pasta) return(pizza + pasta)
Obviously is wrong since it gives me error but I don't know why and what should be the right form.
def add(pizza, pasta):
float(pizza, pasta)
return(pizza + pasta)
4 Answers
Kourosh Raeen
23,733 PointsApply float to each argument individually:
def add(pizza, pasta):
a = float(pizza)
b = float(pasta)
return a + b
Chris Freeman
Treehouse Moderator 68,441 Pointsfloat
takes a single argument and returns a result. Also your return is indented too far and it isn't a function. It's a keyword so parens not needed:
def add(pizza, pasta):
fpizza, fpasta = float(pizza), float(pasta)
return fpizza + fpasta
Gianmarco Mazzoran
22,076 PointsCiao Giacomo Melzi,
un metodo rapido oltre a quelli giร postati รจ questo:
def add(pizza, pasta):
return float(pizza) + float(pasta)
Giacomo Melzi
3,095 PointsThanks guys! :)