I have two list:
main_list = [\'Smith\', \'Smith\', \'Roger\', \'Roger-Smith\', \'42\']
master_list = [\'Smith\', \'Roger\']
I want to coun
You can do it other way around. Create list that will contain only elements from main_list
that have substring from master_list
temp_list = [ string for string in main_list if any(substring in string for substring in master_list)]
Now temp_list
looks like this:
['Smith', 'Smith', 'Roger', 'Roger-Smith']
So the length of temp_list
is your answer.