Project: Add a surname

Write a function named add_surname that takes a list of first names. It returns a new list holding only the names that start with "K", each with the surname "Hoffman" added after a space. You can assume every name starts with a capital letter. For example, given this list:

["Kiki", "Krystal", "Pavel", "MaryKay", "Annie", "Koala"]

the function returns:

['Kiki Hoffman', 'Krystal Hoffman', 'Koala Hoffman']

Save the file as add_surname.py.

Show a solution

Try the project on your own first. This is one working solution, followed by its tests. Press Run to run the tests. Read them to see what thorough testing looks like, then change the solution and run again to watch a test fail. The testing tools used here (classes and unittest) are not part of the course yet, so do not worry about how they work.

Projects run on your own computer, so you tell us when you are done.