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

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?