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

Christian Geib
Christian Geib
826 Points

Stuck at this question - error message, not supposed to use while loop as well?

Here's my stab at it:

def loopy(items): # Code goes here items = [] while True: new_items = input(" ")

                for new_items:
                        print(items)

Am not supposed to involve a while loop?

breaks.py
def loopy(items):
    # Code goes here
    items = []
            while True:
            new_items = input(" ")

                    for new_items:
                            print(items)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

These and later challenges are tested using an automated checker that will call the function with various values assigned to items. The is no need to use a while loop or use the input() function. Your code is also resetting the input value back to an empty list. Removing these statements leaves you with:

def loopy(items):
    # Code goes here
    #items = []
    #while True:
    #    new_items = input(" ")

    for new_items:
        print(items)

This is closer. Now the for loop syntax is incorrect.

    # loop over the items
    for item in items:
        print(item)

Post back if you need more help. Good Luck!!

Christian Geib
Christian Geib
826 Points

Hi there, Chris, thanks for your response, if I cut out the while loop and the input, I think I would just use:

def loopy(items):
    # Code goes here
      for item in items:
            print item

but that still gives me a generic 'Bummer, Try again' error message.