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
UGUR YILMAZ
494 PointsCan someone tell me what is wrong with this code? Thanks. There is an error in line 21
new_list=[]
def show_help(): print(""" Enter "DONE" to stop adding items Enter "HELP" to see help menu Enter "SHOW" to see the current list """)
def show_list():
print("Here is your list:")
for item in new_list: print(item)
def add_item(new_item): new_list.append(new_item) print("İtem added")
show _help()
while True: new_item=input(" > ")
if new_item=="DONE": break elif new_item=="HELP": show_help() elif new_item=="SHOW": show_list() else: add_item(new_item)
show_list()
1 Answer
Jennifer Nordell
Treehouse TeacherI'm sorry, I actually can't tell you what's wrong with your code. But I'm guessing it's an indentation error somewhere. Because when I put it in and indent everything correctly, it runs fine! I took the liberty of adding a line or two of code that will actually print out the list. Take a look!
new_list=[]
def show_help():
print(""" Enter "DONE" to stop adding items Enter "HELP" to see help menu Enter "SHOW" to see the current list """)
def show_list():
print("Here is your list:")
for item in new_list:
print(item)
for item in new_list:
print(item)
def add_item(new_item):
new_list.append(new_item)
print("İtem added")
show_help()
while True:
new_item=input(" > ")
if new_item == "DONE":
break
elif new_item == "HELP":
show_help()
elif new_item=="SHOW":
show_list()
else: add_item(new_item)
show_list()
There has to be an indentation error you're missing somewhere. Hope this helps!