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.
Sean Frye1,167 Points
Hm. Am I close at all on this?
I feel I followed the video precisely and looked at my notes and understood, but I guess I don't have this. Am I any close on this or am I way off? I think given more practice, I'll get this down, I just am not sure where I am on this.
def loopy(items): while True: new_item = input("> ") if new_item == "STOP": break items.append(new_item) for item in items: print(items)
Cooper Runstein11,836 Points
The answer below worked for me, it should work for you too. Notice in your initial attempt you're printing out "items" which is an array, whereas "item" is each individual object in that array. Also Python is super space sensitive, so make sure you're using correct spacing each time.
def loopy(items): for item in items: if item == "STOP": break print (item)
Oszkár FehérTreehouse Project Reviewer
Hi Sean. You are close enough, the for loop it's needed but the while and input() you don't need and it's not required after the for statement you can do
if item == 'STOP': break else: print(item)
it item != 'STOP': print(item) else: break
in both ways it will work. I hope this helps you out. Happy coding