Advertisement
Guest User

Untitled

a guest
Jan 28th, 2022
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. def check_winner(_dict):
  2.     for key, value in _dict.items():
  3.         if value < 250:
  4.             continue
  5.         _dict[key] -= 250
  6.         if key == "shards":
  7.             print("Shadowmourne obtained!")
  8.         elif key == "fragments":
  9.             print("Valanyr obtained!")
  10.         elif key == "motes":
  11.             print("Dragonwrath obtained!")
  12.         return True
  13.     return False
  14.  
  15.  
  16. def print_dict(_dict):
  17.     for key, value in _dict.items():
  18.         print(f"{key}: {value}")
  19.  
  20.  
  21. dict_items = {"shards": 0, "fragments": 0, "motes": 0}
  22. dict_junk = {}
  23.  
  24. winner = False
  25. while not winner:
  26.     line = input().split()
  27.     for i in range(0, len(line), 2):
  28.         quantity = int(line[i])
  29.         item = line[i + 1].lower()
  30.  
  31.         if item in dict_items.keys():
  32.             dict_items[item] += quantity
  33.         else:
  34.             if item not in dict_junk:
  35.                 dict_junk[item] = 0
  36.             dict_junk[item] += quantity
  37.            
  38.         winner = check_winner(dict_items)
  39.        
  40.         if winner:
  41.             break
  42.  
  43. print_dict(dict_items)
  44. print_dict(dict_junk)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement