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

jordan GERMINARO
jordan GERMINARO
281 Points

please tell me what im doing wrong

number = int(input("what number would you like to square?"))

im getting an eof error for this line of code and i cant figure out why

3 Answers

Can u post the all code? EOF error means that ur missing a ( or ) at the end of the file this line is fine, u dont get any errors on there

jordan GERMINARO
jordan GERMINARO
281 Points

def square (number): answer = number*number result answer

number = int(input("what number square?"))

print (answer)

You have few erros. u define a function named "square" and u didnt call her anywhere. First u need to get input from the user >>> call the function and store the result >> print the result.

def square (number):
   return number * number 


number = int(input("what number square?"))
result = square(number)
print(result)
jordan GERMINARO
jordan GERMINARO
281 Points

def square (number): return number*number

number = int(input("what number to square?")) answer = square(number) print ("the square of {} is {}".format(number,answer))

what about this... it still says I have an eof

def square (number):
   return number * number 


number = int(input("what number square?"))
result = square(number)
print("the number is {} and the result is {}".format(number,result))

i runned this code and it works just fine, try it in another workspace maybe?