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.
What is the answer? I don't know if I'm doing the multiplication correctly because this language is chaos.
Should I be putting the result of it into a variable? Is there a math function I didn't use properly? I don't remember from earlier videos and I don't want to have to search for it to figure out how simple math works. I'm operating under the assumption python knows the difference between values... because that's how this language is sold so... what did i do wrong here?
def product(num1, num2): num1 * num2 return product(2,4)
Bapi Roy14,237 Points
def product(num1, num2): return num1 * num2 product(2,4)
This is correct format
Sławomir Lasik7,792 Points
In function You do not store anywhere the product from num1 * num2 operation. This can be done by either assigning this to a new variable
prod = num1 * num2
or returning instantly
return num1 * num2
return in the last statement of your function will return None. After return you must give what you want to return
def prod(num1, num2): prod = num1 * num2 return # this will return None and thus None printed on Your console print(prod(2, 3))