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.
for this challenge, do we need to add items in a big list, then print each item in the list?
def loopy(items): for item in items print(item) if item == "STOP" break
Jennifer NordellTreehouse Teacher
Hi there! First, Treehouse is going to send in their own list (and we have no idea what it is). So no, you don't have to make your own list.
You have some indentation problems, and you've forgotten a few colons. Remember, we use a colon on the line before we start a new code block.
Also, you have a small logic error. Your code as it is now will look at the item and then print it. Then it will evaluate if it was "STOP" or not. Which means that every list will print out "STOP". We want it to break out before it gets to print out STOP. Take a look at my solution and see if it makes sense:
def loopy(items): for item in items: if item == "STOP": break print(item)
Hope this helps!
Just one more thing to add to your response Jennifer, you forgot to include the else statement after the break.
def loopy(items): for item in items: if item == "STOP": break else: print(item)
Oh that's strange, my objective wouldn't say Correct until I added the else statement... Why isn't the else required? Thank you!
Thanks! Your profile is amazing by the way. Definitely an inspiration!