given a list of first names, I want to find out their full names in another list.
What I have is:
group = [ "Calderon Juan", "Bramel Joshua", "Davis Decurious", "Hernandez
Hilda", "Martinez Francisco", "Dixon Quanzie", "Johnson Landry", "York
Alex", "Mercer Jacob", "Perez Ricardo", "Bowie Emily", "Huber Grayson",
"Stucker Nicholas", "Cole Christopher", "Caron Michael", "Caronni Vas",
"Rittenberry Grant"]
people_to_find = ["Caron", "York", "Dixon", "David", "Andrew"]
for s in group:
for item in people_to_find:
if item in s:
print item + ", found in: " + s
The output is:
Dixon, found in: Dixon Quanzie
York, found in: York Alex
Caron, found in: Caron Michael
Caron, found in: Caronni Vas
It is not perfect as it doesn’t do an exact matching. For example,
Caron, found in: Caronni Vasly
What I want to find out is exactly “Caron”, not any word has a part as “Caron”.
Besides I refind the short list to:
people_to_find = ["Caron ", "York ", "Dixon ", "David ", "Andrew "]
What would be a good solution? Thank you.