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 Continue

I keep getting "Didn't find the right items being printed" error message. My code works in Workspaces. Need Help.

I ran my code in the Workspaces and it seems to work. I don't know why I keep getting "Didn't find the right items being printed." The code should check for the letter "a" in the first item, if it finds it continue to the next item and print that item. If it does not find an "a" as the first letter in the first item print the current member. My code does that. Where am I going wrong here???

breaks.py
def loopy(items):
    items=["abc","xyz"]
    for item in items:
        if item[0] == "a":
            continue
        print(item)
        if item[0] != "a":
            break
            print(items[0])

1 Answer

Steven Parker
Steven Parker
221,902 Points

There's a few issues here:

  • the "items" will be passed to the function, you should not set them with a literal
  • the break statement ends the loop prematurely
  • the second "if" isn't needed as the item has already been printed