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

Carl Larsen
Carl Larsen
1,061 Points

Deleted the work from the previous task...

So as the professional programmer that I am, I have deleted the code from the previous task... and I don't know what I had written before this part of the course.

Every time i try to run the code it says something along the lines of "square not defined" with this little note;

Important: In each task of this code challenge, the code you write should be added to the code from the previous task.

If anyone could help me figure this out, that would be splendid, Carl from Denmark

squaring.py
def square (number):
    area = number**2
return area

3 Answers

Steven Parker
Steven Parker
231,269 Points

You might be confusing task with challenge. Each challenge begins fresh, but when it has multiple tasks you keep adding to the code.

I tried your code in the challenge and got a more helpful error message: "Bummer: SyntaxError: 'return' outside function". You just need to indent that last line and you'll pass task 1.

When you move on to task 2, you'll leave the function as-is and add some code below it.

Carl Larsen
Carl Larsen
1,061 Points

Okay, I just tried running it again with the last line indented, but now I get the following message;

AssertionError: False is not true: Make sure you call the square function, and pass it 3

Have no Idea what this means, any advice?

Steven Parker
Steven Parker
231,269 Points

Now it sounds like you're working on task 2, but the code above (even with the indent) just completes task 1.

You still need to follow the instructions for task 2 and add the additional code to call the function with the proper argument and store what it returns.

Carl Larsen
Carl Larsen
1,061 Points

Alright, excellent. It makes sense and works now. Thank you!