How to check if a list contains any elements of another list Python

1 Answer

0 votes
lst1 = [3, 6, 4, 8, 9] 
lst2 = [1, 4, 7]
  
result =  any(elem in lst1  for elem in lst2)
  
if result:
    print("true")    
else :
    print("false")
 
 
  
'''
run:
  
true
  

 



answered Aug 14, 2019 by avibootz
...