I want to create a function that removes all of the middle name and leaves the First and Last name when given the format First, Middle, Last.
So far, I have
def clearmidname(listnames):
for name in listnames:
name = name.split()
del name[1]
new = " ".join(name)
return new
For example,
listnames = ["Orpah Gail Winfrey", "Montero Lamar Hill", "Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santísima Trinidad Ruiz y Picasso"]
print(clearmidname(listnames))
would give me
["Orpah Winfrey", "Montero Hill", "Pablo Picasso"]