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 trialChristopher Hill
1,425 PointsHow do I call my new function and call past in the argument 3?
def square(number):
return number * number
result = number * number * 3
2 Answers
Ave Nurme
20,907 PointsHi Christopher
I believe you are stuck on Challenge Task 2 of 2. Let's walk you through this step by step.
Here's the text from the challenge:
Great now that you have created your new square
method, let's put it to use.
Under the function definition, call your new function and pass it the argument 3
.
Since your square
function returns a value, create a new variable named result
to store the value from the function call.
So, you created your new square method, great!:
def square(number):
return number * number
For step no 2 we have to call our new function, here's how to do it in general:
square()
So, calling a function means you just add a set of parens after the name of your function.
Next, we have to pass the function the argument 3
, here's how to do it:
square(3)
And finally, we have to create a new variable called result
and store the value from the function call:
result = square(3)
Here, we assign the value square(3)
to a variable called result
.
So if we put the pieces together, here's the final code which should pass the challenge:
def square(number):
return number * number
result = square(3)
So, the number 3
actually goes instead of number
in
def square(number):
and
return number * number
returns 3 * 3
.
I hope this makes sense!
Ave Nurme
20,907 PointsGreat to hear that, Christopher! Happy to help! :-)
Christopher Hill
1,425 PointsChristopher Hill
1,425 PointsThis helps a ton, thank you so much!!