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 trialLaknath Gunathilake
1,860 PointsHELP function not working
When I run this code, the HELP function doesn't seem to work
shopping_list=[]
def show_help():
print out instructions on how to use the app
print("what should I do today?")
print("""
Enter 'DONE' to stop adding items. Enter 'HELP' for this help Enter 'SHOW' to see the current list """)
show_help()
while True: #ask for new item new_item= input("> ") if new_item == 'DONE': break elif new_item== 'HElP': show_help() continue #be able to quit the app
add new items to our list
shopping_list.append(new_item)
print out the list
print("here's your list:")
for item in shopping_list: print(item)
1 Answer
Grigorij Schleifer
10,365 PointsHi Laknath,
I see a typo inside this line:
elif new_item== 'HElP'
# change it to HELP :)
I have refactored your code a little:
shopping_list = []
# print out instructions on how to use the app
def show_help():
print("what should I do today?")
print("""
Enter 'DONE' to stop adding items.
Enter 'HELP' for this help Enter 'SHOW' to see the current list
""")
show_help()
while True:
# ask for new item
new_item = input("> ")
if new_item == 'DONE':
break
# show_help() continue #be able to quit the app
elif new_item == 'HELP':
show_help()
# add new items to our list
shopping_list.append(new_item)
# show list
print("here's your list:")
for item in shopping_list:
print(item)
I hope I could help.
Grigorij
Laknath Gunathilake
1,860 PointsLaknath Gunathilake
1,860 Pointsawesome, thank you. I figured that I had typed "HElP" instead of "HELP"
Grigorij Schleifer
10,365 PointsGrigorij Schleifer
10,365 PointsGreat !!!!!
I am glad I could help you Laknath :)
See you in the forum