Advertisement
simeonshopov

Hero Inventory

Apr 9th, 2020
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #!usr/local/bin/python3.8
  2. # -*- coding: utf-8 -*import
  3.  
  4. heroes = input().split(', ')
  5. info = {}
  6.  
  7. while True:
  8.     stuff = input()
  9.     if stuff == 'End':
  10.         break
  11.     tokens = stuff.split('-')
  12.     name = tokens[0]
  13.     item = tokens[1]
  14.     cost = int(tokens[2])
  15.     if name not in info:
  16.         info[name] = [[item], cost]
  17.     elif item not in info[name][0]:
  18.         info[name][0].append(item)
  19.         info[name][1] += cost
  20.  
  21. [print(f'{x} -> Items: {len(y[0])}, Cost: {y[1]}') for x, y in info.items()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement