[Solved] Grocery Store for Python


I think the problem is in the part where you insert your item into the cartList. You only insert the item, not the money with it. So in the return part, it must be:

if ask == 'return':
    ret = input('What item do you want to return?\n')
    for i in cartList:
        if ret==i:
        ...

Or if you want to insert both the item and money into cartList, it should be:

...
if ques == 'y':
    money = money - i[1]
    print('\nYou now have $', money)
    cartList.insert((item,i[1]),0)
...

Also, you haven’t build the if-else part for quest(Y/N)
If the user input is Y, you might want to use the del method to delete that element from cartList

solved Grocery Store for Python