Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_dict = {}
- my_words = input().split(' | ')
- for words in my_words:
- word, definition = words.split(': ')
- if word not in my_dict:
- my_dict[word] = []
- my_dict[word].append(definition)
- teacher_words = input().split(' | ')
- command = input()
- if command == 'Test':
- my_dict = {key: value for (key, value) in my_dict.items() if key in teacher_words}
- for word, definitions in sorted(my_dict.items()):
- print(f'{word}:')
- for definition in sorted(definitions, key=lambda kvp: -len(kvp)):
- print(f' -{definition}')
- else:
- for word, definition in sorted(my_dict.items()):
- print(word, end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement