Write a function lastfirst() that takes a list of strings as a parameter. Each string in the list has the format 'Last, First' where Last is a last name and First is a first name. The function lastfirst() returns a list containing two sublists. The first sublist is a list of all the first names and the second sublist is a list of all the last names. The following shows how the function would be called on an example parameter:
######################### def lastfirst(a): # list of last names lastNames=[] # list of first names firstNames=[] for x in a: n=x.find(',') # look for the comma lastNames.append(x[0:n]) # extract all symbols before ',' firstNames.append(x[n+2:]) # extract all symbols after ', ' return [firstNames, lastNames] # print the result
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment