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 trialJesse Peck
234 PointsFunctions and calling them in python
The Challenge Task is that I have to first, "Under the function definition, call your new function and pass it the argument 3." Then my next one is, "Since your square function returns a value, create a new variable named result to store the value from the function call." Honestly I've tried so many ways I just need someone who has a lot of experience in python to help me do it and understand it the right way.
def square(number):
return(number * number)
2 Answers
Tim Rach
Full Stack JavaScript Techdegree Student 25,127 PointsYou call a function by typing the name of your function, and inside brackets the argument for it. So in your case
def square(number):
return(number * number)
square(3)
Magnus Lindberg Christensen
2,231 PointsThe part you have postet is correct.
The challenge is asking you to store the function call (square(3)), and not the function in general or the return value.
therefore your code should look like the following:
result = square(3)