Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions employee-salary-calculation/shopping_cart_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)
Expand Down