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
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment