Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

intersection in list

def intersection(lst1, lst2): 
    lst3 = [value for value in lst1 if value in lst2] 
    return lst3 
  
# Driver Code 
lst1 = [4, 9, 1, 17, 11, 26, 28, 54, 69] 
lst2 = [9, 9, 74, 21, 45, 11, 63, 28, 26] 
print(intersection(lst1, lst2)) 
Comment

How to Get the Intersection of Sets in Python

firstSet = {2, 3, 4, 5}

secondSet = {1, 3, 5, 7}

print(firstSet & secondSet)
# {3, 5}
Comment

intersection of two lists using set method

# Python program to illustrate the intersection
# of two lists using set() method
def intersection(lst1, lst2):
    return list(set(lst1) & set(lst2))
 
# Driver Code
lst1 = [15, 9, 10, 56, 23, 78, 5, 4, 9]
lst2 = [9, 4, 5, 36, 47, 26, 10, 45, 87]
print(intersection(lst1, lst2))
Comment

intersection of list of sets

u = set.intersection(*setlist)
Comment

PREVIOUS NEXT
Code Example
Python :: django extract array from post matrix 
Python :: python login to O365 
Python :: c Pythagorean triples 
Python :: how to check if a dictionary is empty in python 
Python :: (Word or Phrase to Phone-Number Generator) python 
Python :: python can a imported module get variables from main module 
Python :: binary table dataframe 
Python :: convert html to python 
Python :: search number is complete or no python 
Python :: reload module 
Python :: recover dict from 0-d numpy array 
Python :: bootstrap 5 in django 
Python :: Can the string find method be used to search a list? 
Python :: COLLECTING 
Python :: abstract user in django 
Python :: select features and label from df 
Python :: How do I know which animation is playing animation player 
Python :: wexpect in python 
Python :: url python 
Python :: dataset.shape 
Python :: sort an array in python 
Python :: read file bytes python 
Python :: regular expression in python 
Python :: python check if key exist in dict 
Python :: python remove last 4 characters from string 
Python :: select python interpreter vscode 
Python :: float and int difference 
Python :: python fme logger 
Python :: typing racer 
Python :: when to use map function in python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =