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 trialnandini sn
901 PointsProblem am facing try again error
def loopy(items): for i in items: if items == 'STOP' break print(items)
i need to loop all items in items until i get STOP , kindly help where am facing error
def loopy(items):
for i in items:
if items == 'STOP'
break
print(items)
# Code goes here
2 Answers
Stuart Wright
41,120 PointsThere are three issues with your code:
1) 'items' refers to the entire list. You need to amend your if statement and print statement to instead refer to a single element ('i' in this case).
2) You are missing the colon at the end of your if statement.
3) Your break statement is not correctly indented. It should be indented further to make clear that it is inside the if block.
Douglas North
10,884 Pointsyou are saying if ITEMS when you should compare it to each iter so replace with i
nandini sn
901 Pointsnandini sn
901 PointsThanks again :)