python how to check string occurence between two list

Solutions on MaxInterview for python how to check string occurence between two list by the best coders in the world

showing results for - "python how to check string occurence between two list"
Yannik
17 Sep 2017
1'''I know this is an old question, but if anyone was wondering how to get matches or the length of the matches from one or more lists. you can do this as well.'''
2
3a = [1,2,3]
4b = [2,3,4]
5c = [2,4,5]
6
7'''To get matches in two lists, say a and b will be'''
8d = [value for value in a if value in b] # 2,3 
9
10'''For the three lists, will be'''
11d = [value for value in a if value in b and value in c] # 2
12len(d) # to get the number of matches
13
14#also, if you need to handle duplicates. it will be a matter of converting the list to a set beforehand e.g
15a  = set(a) # and so on