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 Product

Maggie Wolff
Maggie Wolff
495 Points

python basics challenge task 1 of 1 product

I changed the code 3 or 4 times, and it won't work

product.py
def product(num1 * num2)
num1 = 128
num2 = 5

2 Answers

Buddhima Sehan
Buddhima Sehan
3,820 Points

Hello Maggie Wolff,

def product(num1 * num2)

We can not do any sort of arithmetic operation inside the parentheses of a function other than creation of arguments.

num1 = 128 num2 = 5

Question did not mention any sort of assignment for the arguments that we are supposed to create. Moreover you are missing the return command as well.

Correct Answer:

def product(argument_one,argument_two):
    return argument_one * argument_two

I have created a function name product with two arguments passed which are "argument_one,argument_two" afterwards according to the question I have returned the two arguments after it is multiplied in the return command itself.

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

A properly code function has the following parts:

def function_name(parameters, separated, by, commas): # line ends in a colon
    # subsequent lines indented (preferred style is 4 spaces)
    # A 'return' statement passing results back to the calling code
    return value_to_be_returned

The value returned can be an expression, such as, return num1 * num2

Post back if you need more hints. Good luck!!