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

TRACI JOHNSON
TRACI JOHNSON
363 Points

Stuck on Challenge - My code work, but there is still something wrong with it. Please look at this code

def square(number): return number * 2

number_due = int(input("What is your number? "))

number_squared = int(number_due ** 2)

print("The square of", number_due, "is {}".format(number_squared))

1 Answer

Using input() when submitting code for the challenges usually confuses the checker. Try assigning a value to number_due directly, such as number_due = 5.

The lines

number_due = int(input("What is your number? "))
number_squared = int(number_due ** 2)
print("The square of", number_due, "is {}".format(number_squared))

will print out the square of the input, but they don't call the function square to do it. Try changing number_squared = int(number_due ** 2) to use the square function.

The square function currently returns the number twice its input, rather than squaring its input.

When posting in the forums, you can format it with Markdown by surrounding the code with three backticks (`) followed by the name of the language, python, on the line before the code block and three backticks on the line after the code block.