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
145,805 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 :)