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 trialCHENG HAO.HSUAN
663 PointsI don't know where am i wrong.
I don't know where am i wrong. I print so many times but just not right. Where am I wrong?
def loopy(items):
# Code goes here
items_list = []
print("Add your new item: ")
print('Enter the "STOP" to stop add')
while True:
new_item = input("< ")
if new_item == "STOP":
break
items_list.append(new_item)
print("Here is your list: ")
for items in items_list:
print(items)
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsThis challenge is about creating a function that accepts an iterable as an argument then loops over that argument print the items until a "STOP" is reached. There isn't a need to interactively prompt the user for input. Removing the interactive parts from your code, and changing the while
loop to a for
loop, and fixing the indentation gives the following passing code.
def loopy(items):
# Code goes here
# items_list = []
# print("Add your new item: ")
# print('Enter the "STOP" to stop add')
# while True:
# new_item = input("< ")
for new_item in items:
if new_item == "STOP":
break
# items_list.append(new_item)
# print("Here is your list: ")
# for items in items_list:
print(new_item)
CHENG HAO.HSUAN
663 Pointsthanks a lot