Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stores = {}
- while True:
- tokens = input().split('->')
- if tokens[0] == "END":
- break
- else:
- command = tokens[0]
- store = tokens[1]
- if command == "Add":
- store_items = tokens[2].split(',')
- if store not in stores:
- stores[store] = []
- for item in store_items:
- stores[store].append(item)
- elif command == "Remove":
- if store in stores:
- del stores[store]
- stores_sorted = sorted(stores.items(), key=lambda a: (len(a[1]), a), 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