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

I am having a problem understanding how to fix this error for my Basketball Team Stats Tool

Hi Guys

I do not understand how to fix this error and i've tried fixing it but it does not seem to work. Please could someone help me.

This is the error message: File "/home/treehouse/workspace/app.py", line 48
return panthers, bandits, warriors, team_lists
^
SyntaxError: 'return' outside function

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

When return is outside a function, usually the issue is the return statement needs to be indented further to the right.

This can also be caused by a preceding line also needed to be indebted to be inside a function. An insufficiently indented previous line will cause the parser to think the function code block has been “closed” thus making the subsequent return outside of the function.

Post back if you need more help. Good luck!!!

Thank you Chris i will try this.

Hi Danielle Murray! If you are still having issues feel free to reach out in Slack with any questions you might have. We can take a look at your code and help you with any TechDegree related questions. :)

Happy coding!

Thank you so much Mel.