Duplicate and Nonduplicate Names X24103


Statement
 

pdf   zip

html

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. Each string in the list has the given name and the family name of a person, in this order, and separated by spaces.

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.

Public test cases
  • Input

    print(d(['Donald Trump', 'Hillary Clinton', 'Lyndon Johnson', 'William Clinton', 'William Taft', 'Andrew Johnson', 'Andrew Jackson', 'Donald Duck']))
    print(d(['George Washington', 'Denzel Washington', 'Washington Irving', 'George Michael', 'Boy George']))
    
    

    Output

    (['Hillary', 'Lyndon'], ['Clinton', 'Johnson'])
    (['Boy', 'Denzel', 'Washington'], ['Washington'])
    
  • Information
    Author
    ProAl
    Language
    English
    Official solutions
    Python
    User solutions