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 trialPavel Pokor
3,145 PointsWhy 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
2,186 PointsHi 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
2,564 PointsHinh Phan
2,564 PointsThat's help. Thank Frank !
Close bag
if item_took == ('DONE'):