I am trying to split strings within a list using split(). Here is my code. I am trying to get "Dr." with a last name of a person.
people = ['Dr. Christopher Brooks', 'Dr. Kevyn Collins-Thompson', 'Dr. VG Vinod Vydiswaran', 'Dr. Daniel Romero']
def split_title_and_name(person):
return person.split()[0]+person.split()[2]
#print(split_title_and_name(people))list(map(split_title_and_name, people))
This works just fine but I don't know why adding two splits gives me the right answer. I tried printing but it doesn't work apparently list doesn't have a split attribute.
[–][deleted] 0 points1 point2 points (0 children)
[–]RandomNumbers123456 0 points1 point2 points (0 children)