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.

Python Python Basics Functions and Looping Create a Function

Harjan Anand
Harjan Anand
780 Points

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 90,669 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.