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 trialAmy Talbott
12,134 PointsNot sure why my code for the product challenge isn't working
I can't figure out why I keep getting a bummer answer for this one. Could someone please give me a hint?
def product(5, cats):
return 5 * cats
2 Answers
annecalija
9,031 PointsHi Amy,
When defining functions, arguments should be variables/placeholders instead of just plain value.
def product(arg_1, arg_2):
Reflect on: how will you be able to call the function if there's nowhere you can place it arguments?
If you want to have a default value, to an argument, you can do:
def product(cats, cat_food=5):
That way you can call it either:
>>> product(4,3)
12
or
>>> product(4)
20
Hope this helps.
Damien Watson
27,419 PointsHi Amy, really close, you need to pass in two variables, not one and a number.
It should work if you tweak it to be like this:
def product(number_1, cats):
return number_1 * cats