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

Can i get an answer for this an be given another example? I feel lost

Trying to relay what Craig does in the video isn't making sense to me, is what I'm trying for in the problem simpler than the example in his video?

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

answer = square(number)

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Ryan,

Here is what the challenge is asking:

Create a function named square. It should define a single parameter named number. In the body of the function return the square of the value passed in.

Note that the challenge is not asking you to create a variable called answer, all it is asking you to do is to write the function.

Even if it was asking to create the variable you have created, your function call is passing in an undefined variable, which is causing the crash (hence the error you are getting).

Hope that helps

Cheers

Alex