From 9e86e40d67d0c5e2915ca227f2734dbfba236013 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 16 Sep 2019 18:25:04 +0530 Subject: [PATCH] fixed the dict code to work in python 3 --- employee-salary-calculation/shopping_cart_module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/employee-salary-calculation/shopping_cart_module.py b/employee-salary-calculation/shopping_cart_module.py index f165d80..9a8eea5 100644 --- a/employee-salary-calculation/shopping_cart_module.py +++ b/employee-salary-calculation/shopping_cart_module.py @@ -5,10 +5,10 @@ def __init__(self): def add_item(self,item): "Adding and updating the items into the cart" - if not self.shopping_cart.has_key(item.item_name): + if item.item_name not in self.shopping_cart.keys(): self.shopping_cart.update({item.item_name:item.item_quantity}) else: - for key,value in self.shopping_cart.iteritems(): + for key,value in self.shopping_cart.items(): if key == item.item_name and value == item.item_quantity: print ("The item and quantity you are trying to add are in the shopping cart already,no need to add it") @@ -22,7 +22,7 @@ def remove_item(self,item): "Removing an item from the list" if not self.shopping_cart: print("There is no shopping cart and you cant delete it") - for key,values in self.shopping_cart.iteritems(): + for key,values in self.shopping_cart.items(): if key ==item.item_name and values == item.item_quantity: item_to_remove = key self.shopping_cart.pop(item_to_remove)