Advertisement
mengyuxin

meng.displayInventory.py

Dec 30th, 2017
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. # displayInventory.py
  2. stuff = {'rope': 1,
  3.          'torch': 6,
  4.          'gold coin': 42,
  5.          'dagger': 1,
  6.          'arrow': 12}
  7.  
  8. def displayInventory(inventory):
  9.     print('Inventory:')
  10.     item_total = 0
  11.     for k, v in inventory.items():
  12.         print(str(v) + ' ' + k)
  13.         item_total += v
  14.     print('Total number of items: ' + str(item_total))
  15.  
  16. displayInventory(stuff)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement