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.

Python Python Basics (2015) Logic in Python Product

Not 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

Hi 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)


>>> product(4)

Hope this helps. :blush:

Damien Watson
Damien Watson
27,419 Points

Hi 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