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.
Maggie Wolff495 Points
python basics challenge task 1 of 1 product
I changed the code 3 or 4 times, and it won't work
def product(num1 * num2) num1 = 128 num2 = 5
Buddhima Sehan3,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.
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 FreemanTreehouse Moderator 67,994 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!!