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

Python Python Basics Functions and Looping Create a Function

I'm can't trying to define a function to return a value. How would you create a function to return it's value?

squaring.py
def number(square):
    return square 

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

You've almost got it. But you need to switch the function name and the name of the parameter you're passing in so it that it is named square and receives a number parameter.

def square(number):
    return number

Once you've done that you should make sure you return the calculation that multiplies 1 number by the other.

def square(number):
    return number * number

When you make the function call, that is when you pass in the number value you use as an argument to the function. And that's what you take care of in the next part of the challenge.

Thank you so much