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

Martin Kolejak
Martin Kolejak
279 Points

I don't understand why my code still doesn't work on a website because on a launch workspace it works.

This is my code.

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

number_for_square = int(input("Write a number for square ")) result = square(number_for_square) print("The square of {} is {}.".format(number_for_square, result))

And this is a mistake.

.

Ran 1 test in 0.001s

OK

E

ERROR: test_results (main.TestFunctionDefinitionExecution)

Traceback (most recent call last): File "", line 48, in test_results File "/workdir/utils/challenge.py", line 20, in execute_source exec(src) File "", line 4, in EOFError: EOF when reading a line


Ran 1 test in 0.001s

FAILED (errors=1)

squaring.py
def square(number):
    return(number * number)

number_for_square = int(input("Write a number for square "))
result = square(number_for_square)
print("The square of {} is {}.".format(number_for_square, result))

1 Answer

Steven Parker
Steven Parker
231,269 Points

The instructions only ask you to create the function in task 1. Then, in task 2 you will call the function "and pass it the argument 3".

Your function is OK, but for the challenge you won't need to prompt, input, or print anything. And be sure to pass "3" as the argument when you call the function and assign "result".

Martin Kolejak
Martin Kolejak
279 Points

thank you very much :)