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

What is wrong with my code?

I do not understand what I am doing wrong with my code here. It works in the workspace and repel but it is not working in the quiz section for Python. Any ideas?

import math def square (number): return (choose _a_number * choose_a_number)

Choose_a_number = float(input("Please choose a number? ")) number_square = square (choose_a_number*choose_a_number) print ("The square of your number, {} is" .format (number_square))

The error that I keep getting is Error: test_results (main.TestFunctionDefinitionExecution) Traceback (most recent call last): File " ", line 48, in test_results File "/workdir/utils/challenge.py", line 24, in execute_source exec(src) File" ", line 5, in EOFError: EOF when reading a line

This is my 5th line and it looks correct to me Choose_a_number = float(input("Please choose a number? ")) Again, this code works in the repel and workspace but not on this quiz.

2 Answers

Unless the challenge specifically asks to get user input, calling input() will usually confuse the checker. Try putting in a specific number if you are asked to call the function in the challenge.

def square (number): 
    return (choose _a_number * choose_a_number)

The function uses two variables, number and choose_a_number, but choose_a_number is not given a value within the function. Were these meant to be the same variable?

Choose_a_number = float(input("Please choose a number? ")) 
number_square = square (choose_a_number*choose_a_number)

Capitalization matters in Python, so the variable Choose_a_number has a different name from a variable choose_a_number.

square(2) should return 4. square(2*2) should be equivalent to square(4), which should return 16.

Thank you. I will reassess and give it a try.