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

Python Introducing Lists Build an Application Display the List

Ben McMahan
Ben McMahan
7,921 Points

Here's my solution

Added a few things, such as checking for the command inputs after they had been converted to uppercase and a friendlier show_list()

# Create a new empty list called shopping_list
shopping_list = []

def add_to_list(item):
    Add To List
    Adds a new item to the shopping list
    :param item: Item to be added
    # Add the item to the list
    # Notify the user that the item was added and state the number of items in the list currently
    print("Added! List has {} {}".format(len(shopping_list), "items" if len(shopping_list) > 1 else "item"))

def show_help():
    Show Help
    Shows the menu of available commands
    print("What should we pick up at the store?")
    # Multiline print statement
    Enter 'DONE' to stop adding items.
    Enter 'SHOW' to show the items on the list. 
    Enter 'HELP' for this help.

def show_list():
    Show List
    Prints the shopping list to the screen
    shopping_list_length = len(shopping_list)
    if shopping_list_length == 0:
        print("There are no items on the shopping list. Add one!")
        are_is = "are" if shopping_list_length > 1 else "is"
        item_items = "items" if shopping_list_length > 1 else "item"
        print("There {} {} {} on the shopping list:".format(are_is, shopping_list_length, item_items))
        for item in shopping_list:


# Infinite Loop
while True:
    new_item = input("> ")

    if new_item.upper() == "DONE":
    elif new_item.upper() == 'HELP':
    elif new_item.upper() == 'SHOW':

    # Call add_to_list with a new item as an argument


1 Answer