Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kurzweil777/6cd530d5bd2b71b3c08031f9d53ae3d5 to your computer and use it in GitHub Desktop.
Save kurzweil777/6cd530d5bd2b71b3c08031f9d53ae3d5 to your computer and use it in GitHub Desktop.
Game Inventory
'''Задание - https://yapx.ru/v/HUSTz'''
from collections import Counter
inventory = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12}
def add_to_inventory(base_inventory, added_items):
added_inventory = Counter(base_inventory) + Counter(added_items)
return added_inventory
def display_inventory(any_invent):
print('Inventory: ')
total_number = 0
for item in any_invent:
print(str(any_invent[item]) + " " + item)
return print('Total number of items: ' + str(total_number + any_invent[item]))
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin',
'ruby']
super_inventory = add_to_inventory(inventory, dragonLoot)
display_inventory(super_inventory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment