Compsci 101, uniqueFirstNames
This exercise is for collaborative work during class. Do not fill out early!
Sign in to Google to save your progress. Learn more
Here is a datafile and code for processing the file
Here is a datafile of first and last names, separated by colon if multiple names on a line

Susan Smith:Jackie Long:Mary White
Susan Brandt
Jackie Johnson:Susan Rodger:Mary Rodger
Eric Long:Susan Crackers:Mary Velios
Jack Frost:Eric Lund


def processFile(file):
    '''
    The parameter file is the name of a file with one or more names
    on a line. Each name is two words separated by a blank.
    Multiple names on a line are separated by a colon
    Return a list of names
    '''
    nameList = []
    for line in file:
        listNames = line.strip().split(':')
        [nameList.append(nm.split()) for nm in listNames]
    return nameList

Which of the following is true about this function processFile *
What format is namelist in? *
Write the code for UniqueFirstNames
def uniqueFirstNames(data):
    '''
    The parameter data is a list of lists where each list is two
    strings representing the first and last name of a person.
    Return a list of the unique first names of all the people.
    '''
    uniqueNames = set([])
    #TODO:
Write the code for UniqueFirstNames here *
Names and Netids below
Names (comma separated) *
netid *
netid (partner)
netid (partner)
netid (partner)
Submit
Clear form
Never submit passwords through Google Forms.
This content is neither created nor endorsed by Google. Report Abuse - Terms of Service - Privacy Policy