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 Python Basics (2015) Shopping List App Shopping List Introduction

Pavel Pokor
Pavel Pokor
3,145 Points

Why isn't this version of shopping list code working? Can't figure where I made the mistake.

def shopping_list():
    shopping_items = []
    while True:
        new_item = input("Enter an item you want on the shopping list. To quit type 'DONE' ")
        if new_item.upper == 'DONE':
            print(shopping_items)
            exit()
        else:
            shopping_items.append(new_item)

shopping_list() 

1 Answer

Hi Pavel! You didn't mention what your issue is, so I'm guessing it's that typing DONE (or 'done') doesn't end the loop. The problem is that "upper" is actually a function which requires the "()" after the function call, even if you don't have an argument to give it. That line should read:

if new_item.upper() == 'DONE':
Hinh Phan
Hinh Phan
2,564 Points

That's help. Thank Frank !

Close bag

if item_took == ('DONE'):