You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def create_inventory(items):
inventory_dict={}
for i in items:
if i not in inventory_dict:
inventory_dict[i]=1
elif i in inventory_dict:
inventory_dict[i]+=1
return inventory_dict
def add_items(inventory_dict,items):
for j in items:
if j in inventory_dict:
inventory_dict[j]+=1
if j not in inventory_dict:
inventory_dict[j]=1
return inventory_dict
def decrement_items(inventory_dict,items):
for j in items:
inventory_dict[j]-=1
if inventory_dict[j]<0:
inventory_dict[j]=0
return inventory_dict
def remove_item(inventory_dict,item):
item_List=list(inventory_dict.keys())
for i in item_List:
if i==item:
inventory_dict.pop(i,None)
return inventory_dict
def list_inventory(inventory_dict):
inventory_list=[]
for key in inventory_dict:
inventory_tuple=()
if inventory_dict[key]>0:
inventory_list.append((key,)+(inventory_dict[key],))
return inventory_list
The text was updated successfully, but these errors were encountered:
def create_inventory(items):
inventory_dict={}
for i in items:
if i not in inventory_dict:
inventory_dict[i]=1
elif i in inventory_dict:
inventory_dict[i]+=1
return inventory_dict
def add_items(inventory_dict,items):
for j in items:
if j in inventory_dict:
inventory_dict[j]+=1
if j not in inventory_dict:
inventory_dict[j]=1
return inventory_dict
def decrement_items(inventory_dict,items):
for j in items:
inventory_dict[j]-=1
if inventory_dict[j]<0:
inventory_dict[j]=0
return inventory_dict
def remove_item(inventory_dict,item):
item_List=list(inventory_dict.keys())
for i in item_List:
if i==item:
inventory_dict.pop(i,None)
return inventory_dict
def list_inventory(inventory_dict):
inventory_list=[]
for key in inventory_dict:
inventory_tuple=()
if inventory_dict[key]>0:
inventory_list.append((key,)+(inventory_dict[key],))
return inventory_list
The text was updated successfully, but these errors were encountered: