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 trialmarinmirosevic
3,279 Pointsneed help with code
need help with code
def loopy(items):
# Code goes here
items =[]
While True:
new_item=input("> ")
if new_item =='STOP':
break
items.append(new_item)
print ("Here is your list:")
for item in items:
print(loopy)
7 Answers
Jeremy Hill
29,567 Pointsdef loopy(items):
# Code goes here
for item in items:
if item == 'STOP':
break
else:
print(item)
Make sure that your indentions are correct.
Jeremy Hill
29,567 PointsIf you follow the instructions closely it's hard to miss. It tells you to add a for loop that prints each item but first checks to see if the item is equal to 'STOP' and if it does then break the loop, so
step 1:
for item in items:
step 2:
if item == 'STOP': break
step 3:
else: print(item)
marinmirosevic
3,279 Pointsdef loopy(items): # Code goes here items=[] while True: new_item=input("> ") items.append(new_item) print ("Here is your list:") for item in items: if item == STOP': break else: print(item)
marinmirosevic
3,279 Points''' def loopy(items): # Code goes here items=[] while True: new_item=input("> ") items.append(new_item) print ("Here is your list:") for item in items: if item == STOP': break else: print(item) '''
marinmirosevic
3,279 Pointsseems it doesnt work
marinmirosevic
3,279 Pointsthanks Jeremy
Jeremy Hill
29,567 PointsYou're welcome :)