Advertisement
here2share

# b_inv.py

Feb 14th, 2024
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. # b_inv.py
  2.  
  3. inv = {
  4.     "Gold": 200,
  5.     "Silver": 1500,
  6.     "Ruby": 3,
  7.     "Diamond": 16,
  8. }
  9.  
  10. loot = {
  11.     "Gold": 10,
  12.     "Silver": 80,
  13.     "Diamond": 2,
  14.     "Emerald": 4,
  15.     "Sapphire": 2,
  16.     "Topaz": 1
  17. }
  18.  
  19. new_inv = {k: inv.get(k, 0) + loot.get(k, 0) for k in set(inv) | set(loot)}
  20.  
  21. print(new_inv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement