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 trialMaggie Wolff
495 Pointspython 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
2 Answers
Buddhima Sehan
3,820 PointsHello 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
Treehouse Moderator 68,457 PointsA 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!!