Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Shopping List App Break

Zachary Parke
Zachary Parke
2,796 Points

breaks.py

I have my code attached. I went back to take a look at "Around and Around" to see if I could figure this out. Now I feel like I'm just typing too much out. I'm sad I couldn't figure this one out. Seemed like a simple concept.

breaks.py
def loopy(items):
    while True:
    new_item = input(">")
    if new_item == "STOP":
        break
    items.append(new_item)
    for item in items:
        print(item)
items = []

2 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 26,595 Points

You are very close! I indented the code that runs in the "while True" infinite loop. And add a call to your function with the empty list.

Have fun with Python, it's an amazing language!

def loopy(items):
    while True:
        new_item = input(">")
        if new_item == "STOP":
            break
        items.append(new_item)
        for item in items:
            print(item)

items = []
loopy(items) # and here is where you "call" the function
Zachary Parke
Zachary Parke
2,796 Points

Thanks Jeff. I realized that I actually needed much less code to answer this challenge, but I'm very glad that my code wasn't completely off base. I was just trying to do a little more.

Thanks again.