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

Henry Moreno
Henry Moreno
1,086 Points

FOR LO0OP

I have added this code and still no work

def loopy(items): shopping_list = [] shopping_list.append(items) for items in shopping_list: print(items)

loopy("apples")
breaks.py
   def loopy(items):
    shopping_list = [] 
    shopping_list.append(items)
          for items in shopping_list: 
             print(items)

    loopy("apples")

3 Answers

Hello Henry! I had trouble with these, too. You had "for items" when it should be "item". When you type "for item in items", you're telling the program, literally:"For everything individual item in our list, items - I want you to print that individual item.

We .append() to lists when we want to add a new item to them - you can take that out for this challenge

def loopy(items):
    for item in items:
        print(item)

The challenge is actually separate from what was taking place in the video. Therefore, you do not need to include anything about a shopping list in your code. Your code should only address the functionality specified explicitly in the code challenge.

Thus, for the first part of the challenge you need to create a for loop which prints each "thing" passed into the function via the items parameter.

def loopy(items):
    for item in items:
        print(item)

The second part of the challenge, asks that you break out of the loop if the current item is a string with a value of 'STOP'.

def loopy(items):
    for item in items:
        if item == "STOP":
            break
        print(item)
Henry Moreno
Henry Moreno
1,086 Points

Ted: Thanks that was a big help ..Happy Holidays