string = 'get selected items from the list'
lst_keywords = ['list', 'selected', 'python', 'subset']
res = [ele for ele in lst_keywords if(ele in string)]
then res = ['list', 'selected']
But I only want the first occurrence of element present in the string, like in the string since selected comes first I just want res to output selected
only excluding the list
element from res.
Any ideas of how I can achieve that?