Advertisement
exDotaPro

on_the_way_to_annapurna

Apr 3rd, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. stores = dict()
  2.  
  3. while True:
  4.     info = input().split('->')
  5.     command = info[0]
  6.  
  7.     if command == 'END':
  8.         break
  9.  
  10.     store = info[1]
  11.     items = []
  12.  
  13.     if command == 'Add':
  14.         items = info[2].split(',')
  15.         if store not in stores:
  16.             stores.update({store: [item for item in items]})
  17.         else:
  18.             stores[store] += [item for item in items]
  19.     elif command == 'Remove':
  20.         if store in stores:
  21.             del stores[store]
  22.  
  23. stores = {k: v for k, v in sorted(sorted(stores.items(), reverse=True), key=lambda x: len(x[1]), reverse=True)}
  24.  
  25. print('Stores list:')
  26. for store, items in stores.items():
  27.     print(store)
  28.     for item in items:
  29.         print(f'<<{item}>>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement