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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Harjan Anand](https://secure.gravatar.com/avatar/9dff410b4174fc18623c42dd5a3a163c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Harjan Anand
780 Pointshow do i get the result now
def square(number):
return number * number
1 Answer
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsHey Harjan Anand, task 2 asks you to call your function and create a new variable results
to store the returned value in.
- call a function by adding parens () after the function name. Any arguments are placing inside the parens. So calling
square
with the argument3
would look like
square(3)
- create a new variable is to put a name on the left side of the equals sign =, as in
results =
Putting them together stores the results of the function call in the names variable:
results = square(3)
Edit: to define and call a function would look like:
def func(num):
return num * num
result = func(10)
where the call is not indented. The change in indentation indicates the function definition has ended and code outside of the function is being defined.
Post back if you need more help. Good luck!!!
Harjan Anand
780 PointsHarjan Anand
780 PointsThis is my code so far :
But it keeps saying this :
AssertionError: 25 != 9 : Make sure you store the return value from the function in a variable named result
And I dont understand what I have to do now?
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsUpdated answer to show the form of the answer using similar code. (trying to avoiding posting cut-and-paste answer)
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsThe challenge asks for argument 3 not argument 5.
Harjan Anand
780 PointsHarjan Anand
780 Pointsok now i even changed it what do i do now : and says this: AssertionError: unexpectedly None : Make sure you create a new variable named result
It looks like this :
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsWhat’s the latest version look like?
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsI see after formatting that the assignment to
result
is indented too far. As it is now it’s inside the function.Post back if you need more help. Good luck!!!