Python Python Basics Functions and Looping Create a Function

Jackson Myhre
Jackson Myhre
2,283 Points

squaring

The third line might not be needed to complete this Task but I have no clue what it is I'm missing.

squaring.py
def square(number):
    return number * 2
square(5)
Manuel Canario
Manuel Canario
624 Points

def squareanumber(number): squared = int(number) * int(number) print("{} squared is {}".format(number,squared))

number = input("What number would you like to square? ") squareanumber(number)

This was my funtion and the program mark it as an error. I ran it in the workspace and the function is working.

Chris Freeman
Chris Freeman
Treehouse Moderator 56,953 Points

Manuel Canario, in input function can not be used in most challenges because the checker will only call the function directly and will not provide a response to the input prompt. Also be sure the function name matches what is asked for in the challenge. Good luck!!

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 56,953 Points

You are doubling the number, not squaring it. To square it use a double asterisk: **

Jackson Myhre
Jackson Myhre
2,283 Points

wow.... I can't believe I made that mistake. Thanks!

Manuel Canario
Manuel Canario
624 Points

What about the 0 the computer is saying that I did not validate my program of 0.

Chris Freeman
Chris Freeman
Treehouse Moderator 56,953 Points

Manuel, I suggest starting a new post and include your code. Tag me in the post if you wish.