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

joshua carter
joshua carter
784 Points

Why am I failing the test? I am confused.

I am taking the test that happens after returning values. the question is divided into three parts. The first is create a function "square". The sec is define a single parameter "number". The third is in the body of function return the square passed in. My code reads as follows: def square(number):. answer = number * number. return answer. y_num = int(input("number ")). squared = square(y_num). print("your number squared is {}.".format(squared). My code is a whole working program, so I apologisze for my code. I know part of my problem is it is too long but I can't figure out how to shrink it to make me pass the question.

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

y_num = int(input("number  "))

squared = square(y_yum)

print("Your number squared is {}".format(squared))

3 Answers

you have a spelling mistake.

y_num = int(input("number  "))

squared = square(y_yum)

y_yum should be y_num

joshua carter
joshua carter
784 Points

Thanks for spotting the misspell.

joshua carter
joshua carter
784 Points

I finally figured it out!!!!!!!!!! HURRAY!!!!! THANK YOU EVERYONE WHO RESPONDED!. The answer was just the first part of my code everything else was not needed. I needed to keep things DRY.

joshua carter
joshua carter
784 Points

Thanks everyone for helping me with this problem. However I think I am getting error messages for the quiz, because I am not meeting the answer correctly. I get an error saying TestFunctionDefinitionExecution. There is also a hint saying "each code needs to be added to the code from the previous task.