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

Frank Simser
Frank Simser
2,080 Points

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'):