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

Emmanuel Mejia
Emmanuel Mejia
5,885 Points

EOF error, squaring.py. Trying to create function where number squares itelf. Ex) 5*5 = 25

I keep getting an EOF error when I try to submit this. I tried it on my actual python editor and run it through my command prompt but it works fine. However, when i try to submit this, it simply will not let me. Please help and provide an explanation. Thank you

def square(number):
    return number * number

number = int(input("What number would you like? "))
squared_number = square(number)

print("The number", number, "eqauls to {}".format(squared_number))

Your last statement; you're getting the error because you should concatenate number to the rest of your string

if I wanted to concatenate your variable 'number' to my string it would be like

print("Hello, " + name + "!")

1 Answer

Alex Koumparos
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Emmanuel,

Which task are you stuck on? If it is the first one, the problem is all the code after your function is not part of the solution. You should only be submitting the function itself. Your function is correct so that will pass the challenge.

If the second task, you are being asked to call your function with a particular value, and store the result of the function call in a particular variable name. You have not done this. Again, none of the code you have after your function is part of the required task.

The reason why you are getting the particular error you are experiencing has nothing to do with the last statement, but instead is due to the line where you are asking for user input. Because this interrupts the program flow when the automated checker is just expecting to read a function, it is causing the script to error out. This is trivial to check: just try submitting your code without that line (you'll have to replace the now missing number variable with an integer literal, e.g., 5) and the challenge will pass.