I want to find first list value to another list value in python, where i used match and set and findall other method too but it's not work well in my code.
Here I want to match that pattern is in the longlist and pattern always startwith.
pattern = ['aaa','bbbb','ccc']
longlist = ['aaa845','bbbbPP44','XXX10','aaa420','ccc1','jjj7000','PPPP']
for i in longlist: # longlist is json data, So this line required. After we can do it any code
if filter(pattern.match, i):
print(i)
# other tried
if set(pattern) & set(longlist):
print(i)
Desire output : aaa845, bbbbPP44, aaa420, ccc1
Can anyone suggest best coding style without multiple FOR loop iteration and fastest performance ?