Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

FOR PYTHON: Write a function lastfirst () that takes a list of strings as a para

ID: 641827 • Letter: F

Question

FOR PYTHON: 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. You should assume that there are no spaces between the last name and the comma and that there are an arbitrary number of spaces between the comma and the 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 two example parameters:

Python 3.4.1 Shell File Edit Shel Debug Options Windows Help >>> lastfirst Settle, AmberElam, Joon' Hartman, Cookie' ]) [ I' Amber Joon, 'Cookie', 'Settle,Elam', Hartman'11 >>> 1st las t first (I' settle, Amber i]) >>> 1st [I Amber', I'Settle 11 Ln: 82 Col: 4

Explanation / Answer

def lastFirst(firstName, lastName): separator = ', ' result = lastName + separator + firstName return result print(lastFirst('Benjamin', 'Franklin'))