Python Python Basics Functions and Looping Create a Function

joshua carter
joshua carter
504 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

Damien K. Sedgwick
Damien K. Sedgwick
18,821 Points

you have a spelling mistake.

y_num = int(input("number  "))

squared = square(y_yum)

y_yum should be y_num

joshua carter
joshua carter
504 Points

Thanks for spotting the misspell.

joshua carter
joshua carter
504 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
504 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.