Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- users_dict = {}
- while True:
- command = input()
- if command == 'Statistics':
- break
- command = command.split('->')
- to_do = command[0]
- if to_do == 'Add':
- name = command[1]
- if name not in users_dict:
- users_dict[name] = []
- else:
- print(f'{name} is already registered')
- elif to_do == 'Send':
- name = command[1]
- mail = command[2]
- if name not in users_dict:
- users_dict[name] = []
- users_dict[name].append(mail)
- elif to_do == 'Delete':
- name = command[1]
- if name not in users_dict:
- print(f'{name} not found!')
- else:
- del users_dict[name]
- users_dict_sort = dict(sorted(users_dict.items(), key=lambda x: (-len([1]), x[0])))
- print(f'Users count: {len(users_dict_sort)}')
- for k, v in users_dict_sort.items():
- print(k)
- for j in v:
- print(f' - {j}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement