Hello All,
There are various codes available to find the intersection between two sets in python. But my case is the following:
I want to find the continual common pattern in different lists compared to list1.
(i have underlined the longest common patterns in set a and set b)
a = [1, 2, 3, 5, 8, 9, 4, 9]
b= [1, 3, 2, 3, 9, 4, 9, 5, 9]
common_ordered = [i for in a if i in b]
print common_ordered
The output I get is:
[1, 2, 3, 5, 9, 4, 9]
but my expected output is:
[(2 , 3) , (9, 4, 9)]
Any suggestions would help