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!

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


Loopy function on code challenge won't work, can't break.

def loopy(items): for word in items: print(word) if word == "STOP": break

I've tried replacing word with items and moving the if statement
to the same indentation as for.

1 Answer

Ines Fazlić
Ines Fazlić
Python Web Development Techdegree Student 9,569 Points

Hi, I can't see what you did there, you should post your code to see exactly what was wrong but from the example you wrote I think your problem is that you put the if statement after print word. it should be for word in items: if word == 'STOP': break, else: print (word). this way it first checks if the word is 'stop' and breaks if it is, otherwise it prints the word. if you put print before if it will print no matter what. Also you should uppercase the word just in case user uses lowercase so it would be if word.uppercase () == 'STOP'

Hope this helps :)