Assuming you want to do this for more than one person, you could store each person as a dictionary like Dicts
in a list. This function should do the splitting by spaces and also allows for cases where someone doesn't have a title, i.e., just a first and last name.
def split_names(dict_list):
l = []
for dict_i in dict_list:
new_list = list(dict_i.values())[0].split()
if len(new_list) == 2:
l.append(
{'First': new_list[0],
'Last': new_list[1]}
)
else:
l.append(
{'Title': new_list[0],
'First': new_list[1],
'Last': new_list[2]}
)
return l
Then,
Dicts = {'Name': 'Dr. John Smith'}
split_names(Dicts)
[{'Title': 'Dr.', 'First': 'John', 'Last': 'Smith'}]
Or more generally:
Dicts = [{'Name': 'Dr. John Smith'}, {'Name': 'Mr. Mike Jones'}, {'Name': 'John Doe'}]
split_names(Dicts)
[{'Title': 'Dr.', 'First': 'John', 'Last': 'Smith'},
{'Title': 'Mr.', 'First': 'Mike', 'Last': 'Jones'},
{'First': 'John', 'Last': 'Doe'}]