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 trialLi Tang
1,768 PointsI 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?
def loopy(items):
for item in items:
if item == 'STOP':
break
print item
3 Answers
Alexander Davison
65,469 PointsYou 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
M Gavin
17,906 PointsI 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
1,768 PointsThanks! It is solved.
Li Tang
1,768 PointsThis is a Python version problem. For Python 3.0, it should be "print()".
Li Tang
1,768 PointsLi Tang
1,768 PointsThanks Alex. This is solved!
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsCan you please give me a best answer so this question will get off the "unanswered questions" list in the Community?
Thanks! ~Alex