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

Square code challenge results problem

Hello, I don't know what I've done wrong here and would appreciate some advice. The code below works to ask a number, but then instead of responding with the answer it says "The square of 6 is <function square at 0x7fd687f63e18>. How do I get it to just multiply the number? Thanks!

def square(number): return (number * number)

number = (input("Please enter a number "))

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

3 Answers

You will have to call the function with the parameter. In this case number. Also since input returns a string it will have to be converted to an integer.

print("The square of {} is {}".format(number, square(int(number))))

From what I remember however I don't think this meets the requirement for task 2 of the challenge.

So clearly this is not the right way to do it but I have no clue what a better way would be.

I can't get to the second part anyway b/c the code challenge page is giving me error messages for lines that don't exist.

I found the challenge. Your first two lines of code should pass task 1.

def square(number):
    return (number * number)

Remove any other code for now.