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

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