Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- stores = {}
- while True:
- tokens = re.split("->|,", input())
- if tokens[0] == 'END':
- break
- else:
- command = tokens[0]
- store = tokens[1]
- if command == 'Add':
- if store not in stores:
- stores[store] = []
- for item in tokens[2:]:
- stores[store].append(item)
- else:
- for item in tokens[2:]:
- stores[store].append(item)
- else:
- if store in stores:
- del stores[store]
- stores_sorted = sorted(stores.items(), key=lambda a: len(a[1]), reverse=True)
- print('Stores list:')
- for key, value in stores_sorted:
- print(f'{key}')
- for item in value:
- print(f'<<{item}>>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement