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

Squaring.py exercise failing - not sure why

Hey, Community!

I'm early in the tutorial working on the squaring.py exercise, but it keeps failing. I can plug my code into Workspaces and it works, but I'm wondering what the exercise is looking for that I'm falling short of. Here is my code - any advice is appreciated!:

import math

def square(number): return (number) number = float(input("Enter a number: ")) square = (number * number)

print("The square of {} = {}".format(number, square))

1 Answer

You may want to look at the Markdown Cheatsheet to see how to format your code to make it more readable. As it is, it is hard to see exactly what you are doing.

Also it is best to post your questions directly on the problem you were working on, so that we can actually see what you are trying to solve.

Due to the formatting, I can only guess at what you are doing, but one thing I noticed is that square seems to be both a function and a variable. In this case, it should probably be a function only, just for simplicity.

If you are still lost, please post again, but this time use the Markdown cheatsheet to see how post your code so that we can read it.