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

RMZ .
RMZ .
1,002 Points

Break task 2 of 2

I've been struggle to find the solution, maybe someone could help me out to provide the result and explain to me about the command of the task? I will be much appreciate it, have a good weekend people!

breaks.py
def loopy(items):
    for i in items:
    if current_item == "STOP":
        break
    print (current_item)
    # Code goes here

1 Answer

Hey RMZ! When you perform a for loop your setting the variable for the "current item" after the for statement. Your saying:

for i in item:

Here you are setting the current item to i. That means you dont want to use current_item, you want to use i. Replace your instances of current_item, with i. You also seem to have some indentation issues, remember every time we write a ":" we want to ident for block, you haven't done this in your for loop. Your final code should be:

def loopy(items):
    for i in items:
        if i == "STOP":
            break
        else:
            print(i)

Hope this helps!