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 (2015) Shopping List App Second Shopping List App

Alan Sea
Alan Sea
6,781 Points

show_list() not defined.

https://w.trhou.se/bap9w1d3ub

Why does it keep telling me that the show_list() method call on line 29 of shopping_list_2.py is undefined? The def looks good to me. What am I missing? Thanks in advance!

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

When parsing your code for the first time, line 29 references show_list() before it is defined on line 38. Move the show_list() definition into the beginning of the code. it's also a good practice to place all function definitions before regular code.

Alan Sea
Alan Sea
6,781 Points

So, then, just to clarify, that call doesn't simply point to method's definition, regardless of where the definition is in the code???

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Correct. References are simply pointers to objects in the "namespace". So the referral is looked up on the namespace of objects. If it hasn't yet been defined it will raise an error.