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 Break

Hector Carrillo
Hector Carrillo
934 Points

why isnt it printing the correct "items"

added stop code

breaks.py
def loopy(items):
    for things in items:
        if things == 'STOP':
            break
        else:
            print(items)

1 Answer

You are printing items in the else statement. You should print things.

Also, it's best to have non-plural names for "temporary variables" used in loops.

The name item is probably a better, easier-to-understand name than things. Even the non-plural thing is better than the plural things. Again, you don't have to do this, but if your code is cleaner with better names, it is easier to not make bugs in your code. Also, it's easier to add features if you are on a big project :grin:

I hope this helps. ~Alex

Hector Carrillo
Hector Carrillo
934 Points

yeah true, i see the error. thanks again really going to implement that to my future temp. variables

No problem :wink: