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!
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

Dmitry Manasreh
5,651 Pointsneed help with the challenge
please can any one post his solution here i don't understand exactly what is needed !!

Dmitry Manasreh
5,651 Pointshttps://teamtreehouse.com/library/python-basics/shopping-list-app/refactor this is the link i add ( def main () : ) and move every thing below it to the right and i get error can you show me what exactly should i do please
1 Answer

Umesh Ravji
42,386 PointsHi Dmitry, I'll write out the steps required to complete this challenge. If you are still having trouble, leave a comment.
- On line
22
create a new function, call itmain
, it accepts no arguments. - Select everything from line
23
to the end of the code, and indent it so that it is now inside your newly created function.

Dmitry Manasreh
5,651 Pointsit is exactly what i am doing , still doesn't work
def main () :
show_help()
# make a list to hold onto our items
shopping_list = []
while True:
# ask for new items
new_item = input("> ")
# be able to quit the app
if new_item == 'DONE':
break
elif new_item == 'HELP':
show_help()
continue
elif new_item == 'SHOW':
show_list(shopping_list)
continue
add_to_list(shopping_list, new_item)
show_list(shopping_list)

Umesh Ravji
42,386 PointsDon't forget to make sure that everything is indented, so that it is inside the main
function :)
def main():
show_help()
# make a list to hold onto our items
shopping_list = []
while True:
# ask for new items
new_item = input("> ")
# be able to quit the app
if new_item == 'DONE':
break
elif new_item == 'HELP':
show_help()
continue
elif new_item == 'SHOW':
show_list(shopping_list)
continue
add_to_list(shopping_list, new_item)
show_list(shopping_list)
Edit, sorry it may just be the extra space you have in def main() :
that is causing the problem. Just remove that if the indentation is fine.

Dmitry Manasreh
5,651 Pointsthank you !!!!
Umesh Ravji
42,386 PointsUmesh Ravji
42,386 PointsWhat challenge do you need help with? If you have any code, share it with us :)