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

function is correct but getting EOF error

I've entered the right syntax for the function and tested it out on the workspace however, I'm getting an EOF Error. Did I not do something right?

squaring.py
import math

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

number = int(input("enter a number "))
total = number * number

print("your square is", total)
Phil Thomas
Phil Thomas
4,563 Points

Hi, I'm learning also so I may not be correct, but it looks life you've created the function and then not used it. You've instead tried to complete this manually.

After you've taken the user input, and created the variable 'total', use this input to pass as an argument into the function. I've written out the code below, which seems to work:

import math

def square(number):
    return(number * number)

number = int(input("enter a number: "))
total = square(number)

print("your square is", total)

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Uziel,

Are you stuck on the first part? If so, you have a lot of code that isn't being asked for, which might be tripping up the interpreter.

You are only being asked to write the function, so you shouldn't have any of the lines after your function. The Challenge will take care of running your function, so you should only write the code requested.

Also, you don't need to import the math library, all you are doing is multiplying two values, so you can just write that expression in the normal way.

Hope that's clear

Alex