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

Li Tang
Li Tang
1,768 Points

I believe this should work...

I am trying to finish this challenge question "breaks.py" in Python Basics. It always lets me "Try again"... However, I runs this function in my Python and t works. Could any one point out what could be the problem?

breaks.py
def loopy(items):
    for item in items:
        if item == 'STOP':
            break
        print item

3 Answers

You did really really really great! I'm shocked that you didn't use else (I know it works that way, just most people don't know that you don't need an else!). But, there's only one little minor problem. Just don't forget the parentheses you use for print! Take a look here:

def loopy(items):
    for item in items:
        if item == 'STOP':
            break
        # See that I used parentheses? You forgot to use them! :)
        print(item)

Hope this helps and happy coding! ~Alex :smile:

Li Tang
Li Tang
1,768 Points

Thanks Alex. This is solved!

Can you please give me a best answer so this question will get off the "unanswered questions" list in the Community?

Thanks! ~Alex

I think it's a version problem. You're probably using a different version. Python 3 requires parentheses with print. If you add parentheses to item when you print it, it should work.

print(item)
Li Tang
Li Tang
1,768 Points

Thanks! It is solved.

Li Tang
Li Tang
1,768 Points

This is a Python version problem. For Python 3.0, it should be "print()".