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

Python

Dmitry Manasreh
Dmitry Manasreh
5,651 Points

need help with the challenge

please can any one post his solution here i don't understand exactly what is needed !!

Umesh Ravji
Umesh Ravji
42,386 Points

What challenge do you need help with? If you have any code, share it with us :)

Dmitry Manasreh
Dmitry Manasreh
5,651 Points

https://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
Umesh Ravji
42,386 Points

Hi Dmitry, I'll write out the steps required to complete this challenge. If you are still having trouble, leave a comment.

  1. On line 22 create a new function, call it main, it accepts no arguments.
  2. 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
Dmitry Manasreh
5,651 Points

it 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
Umesh Ravji
42,386 Points

Don'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.