It would be easier to get a count of all words in result_details, using:
If it's already a list, use directly. You will have to match ID to your list, but that's simple enough using index
from collections import Counter ... # If not already a list: delimiter = '|' # Or whatever it is data_list = result_details.strip().split(delimiter) most_common_list = Counter(data_list).most_common()And then find your list of words in most_common_list
If it's already a list, use directly. You will have to match ID to your list, but that's simple enough using index