Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Adrienne Sanders
Adrienne Sanders
321 Points

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.

Adrienne Sanders
Adrienne Sanders
321 Points

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.