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 trial

Matt Caminiti
3,466 PointsMy 'END' keyword is being added to my list in python. How can I stop this from happening?
Hey everyone! I'm making the shopping list app in python and while the code is running fine my 'END' and 'SHOW' keywords are added to my list when inserted. What can I do to stop this from happening?

Jones Dias
13,902 PointsNo problem, man!!
4 Answers

Jones Dias
13,902 PointsWell, try adding shopping_list.append(new_item)
to an else statement. The way you're doing now adds the command to the shopping_list array then filters it on the if chain
.

Jones Dias
13,902 PointsHey Matt! Can you show us the code so we can help you?

Matt Caminiti
3,466 PointsHey, sorry about that! Here it is below -
shopping_list = []
print("""What should we pick up at the store? Enter 'HELP' for keywords ENTER 'SHOW' to show current list""")
def HELP(): print(""" Enter 'END' to stop adding items. ENTER 'SHOW' to show your current list""")
def SHOW(): if new_item == 'SHOW': print(shopping_list)
while True: new_item = input("Add Item Here ") shopping_list.append(new_item)
if new_item == "END":
break
elif new_item == "HELP":
HELP()
continue
elif new_item == "SHOW":
SHOW()
continue
print("Here's your list") for item in shopping_list: print(item)

Jones Dias
13,902 PointsBtw, check your indentation. Python is indentation-structured, so you must be careful with them xD. Here's your example indented and with the changes I proposed.
shopping_list = []
print("""What should we pick up at the store? Enter 'HELP' for keywords ENTER 'SHOW' to show current list""")
def HELP():
print(""" Enter 'END' to stop adding items. ENTER 'SHOW' to show your current list""")
def SHOW():
for item in shopping_list:
print(item)
while True:
new_item = input("Add Item Here ")
if new_item == "END":
break
elif new_item == "HELP":
HELP()
continue
elif new_item == "SHOW":
print("Here's your list")
SHOW()
continue
else:
shopping_list.append(new_item)
continue
Matt Caminiti
3,466 PointsMatt Caminiti
3,466 PointsThank you!