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

this return task question is too vague.

This return task question is too vague im not sure what it asking. it says square but is not defined but is printed.......

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

1 Answer

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

Hi Carlos,

The question wants you to write a function called square that takes a number (number) and then returns a value that is the square of that number (i.e., that number multiplied by itself).

There are a couple of ways you can compute the square, for example you could use the multiplication operator (*) to multiply number by number. Or, you could use the the exponentiation operator (**) to raise number to the power 2. When using either of these operators they take the form a <operator> b, so, for example, multiplying 3 and 4 would be 3 * 4 or raising 6 to the power 3 would be 6 ** 3.

Once you have calculated the value, you just return it. In your current code you have created an infinitely recursive function (calling square inside square) that never actually returns a value it just keeps calling itself until the recursion depth limit is reached, at which point the application will crash.

Hope that clears everything up.

Cheers

Alex