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

Challenge Task 2

What am I doing wrong and can you please explain?

squaring.py
def square(number):
    return number * number
result = square(5)
print(result)

4 Answers

You receive error: AssertionError: 25 != 9 : Make sure you store the return value from the function in a variable named result.

The argument passed in should be 3 not 5. From the instructions:

call your new function and pass it the argument 3

Thank you

Paul Nay
Paul Nay
566 Points

Hello I am wondering why I am getting the incorrect answer. I've tested my code on the workspace to ensure it works.

def square(number): return number ** 2

num_chosen = int(input("Please enter a number to square\n")) result = square(num_chosen)

print("The square of {} is {}".format(num_chosen,result))

Paul, the checker doesn't respond to the input function. For task 1 you just need the function which you have.

def square(number):
    return number ** 2
Paul Nay
Paul Nay
566 Points

Ah thanks for pointing that out. Appreciate the help.