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

gibran erlangga
gibran erlangga
5,539 Points

do you guys have any idea on what "for" syntax code should look like in order to solve this problem?

I'm having difficulty in understanding this topic. The example before is using 'while', and now they want me to create the same code output using 'for'.

breaks.py
def loopy(items):
    for items in items:
        new_items = input("> ")
        items.append(new_items)


    if new_items == "STOP":
        break

    # Code goes here

1 Answer

gibran, try this:

def loopy(items):
    for thing in items:
        if thing == "STOP":
            break
        else: 
            print(thing)
gibran erlangga
gibran erlangga
5,539 Points

solved! many thanks to you, jcorum!