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

EOFError line 20...in the squaring.py, I can not fix it..any suggestion?

import math def square(number): square=number*number return (square)

number= float(input("what is your number for sqr?")) result= square(number) print ("the result of sqr is".format(result))

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

number= float(input("what is your number for sqr?"))
result= square(number)
print ("the result of sqr is".format(result))

3 Answers

You don't need parentheses around the return variable, that is only needed if you are printing something out.

Eduardo Valencia
Eduardo Valencia
12,444 Points

Shouldn't your final line be

print("The result of sqr is {}".format(result))

? You need

{}

as a placeholder.

this works

def square(number):  
    return number ** 2         #you can put the equation directly in the return line

result = square(3)