Duplicate and Nonduplicate Names X29109


Statement
 

pdf   zip

thehtml

Write a function d that checks duplicate and nonduplicate given names and family names in a list of people. Each person is provided by giving their given name and their family name, together in a string. The function must find which given names appear only once as such, and which family names appear more than once as such.

Input

Input is a list of strings, passed as argument of the call to d. Each string in the list has one given name and one family name of a person, in this order, separated by one space. There are no additional spaces anywhere in the strings except for this separator.

Output

Your function must find the given names that appear only once as given names, and the family names that appear more than once as family names. It must return them in two ordered lists: first the ordered list of nonduplicate given names and then the ordered list of duplicate family names. Ordering must be according to the standard function sorted.

Sample session
>>> print(d(['Donald Trump', 'Hillary Clinton', 'Lyndon Johnson',
...      'William Clinton', 'William Taft', 'Andrew Johnson',
...      'Andrew Jackson', 'Donald Duck']))
(['Hillary', 'Lyndon'], ['Clinton', 'Johnson'])
>>> print(d(['George Washington', 'Denzel Washington', 'Washington Irving',
...      'George Michael', 'Boy George']))
(['Boy', 'Denzel', 'Washington'], ['Washington'])
Information
Author
Language
English
Official solutions
Python
User solutions
Python