I have two lists
list1 = ['this', 'is', 'the', 'right', 'string']
list2 = ['this', 'is', 'right']
After comparison I need to find out another list include only
list3 = ['this', 'is']
I have tried it up using intersection, I know it is not the proper solution in my case.
>>> list(set(list1) & set(list2))
['this', 'is', 'right']
It is not the index based comparison.
I need to find the index based comparison. I mean, first compare first words in list1 and list2, if it is match, then take next words in each list then compare that words and so on. If it is not match, then return the matched words only.
Anybody can help me??
If you like noob-style then try this. Easy to understand. That other answer is very much like functional programming, which can be confusing.