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

Great now that you have created your new square method, let's put it to use. Under the function definition, call your

Great now that you have created your new square method, let's put it to use.

Under the function definition, call your

squaring.py
def square(number):
    return number * number

square(3)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Chris Drummond! Looks like you're doing great so far. The second part of the task wants you to create a new variable named result and assign it what is returned by the square function when it is passed a 3.

You're looking for:

result = square(3)

Hope this helps! :sparkles:

Hi Jennifer,

My code doesn't work for this challenge.

def square(number):
    return number * number
    result = square(3)
    print(result)

I am not sure what is wrong.

Regards,

Alana

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Alana Warson! I added some markdown to your comment so that your code would be clear. The final two lines should not be indented inside the function. Rather, their left sides should line up with def

Where you have this:

def square(number):
    return number * number
    result = square(3)

You would need:

def square(number):
    return number * number
result = square(3)

Indentation matters! :smiley: Hope this helps! :sparkles:

Yes, I get confused with what gets indented. Thank you for your help!

Regards,

Alana