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 trialHassan Baukman
2,288 PointsWhy does my code fail?
The Code works using the python shell, why does it fail on the website challenge???
def loopy(items):
for item in items:
if item == 'Stop':
break
else:
print(items)
loopy('STOP')
1 Answer
Steven Parker
231,275 PointsI can see 3 issues, though the last one by itself would likely be ignored by the validator:
- print just one "item" at a time instead of all "items"
- because the comparison is case-sensitive, "Stop" is not the same thing as "STOP"
- you only need to define the function, you don't need to call it yourself