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

intersection of lists in python

import numpy as np
recent_coding_books =  np.intersect1d(recent_books,coding_books)
Comment

python list intersection

# intersection of two lists (lst1 & lst2)
In [1]: x = ["a", "b", "c", "d", "e"]

In [2]: y = ["f", "g", "h", "c", "d"]

In [3]: set(x).intersection(y)
Out[3]: {'c', 'd'}
# has_intersection = bool(set(x).intersection(y)) -> True
Comment

python list INTERSECTION

a = ['apple', 'banana', 'pear']
b = ['fridge', 'stove', 'banana']

a & b == ['banana'] #True
Comment

PREVIOUS NEXT
Code Example
Python :: python typing 
Python :: how to write user input to a file in python 
Python :: dynamic footer in django 
Python :: pip vs conda 
Python :: how to print text in python 
Python :: python Using for loop and list comprehension 
Python :: Python Tkinter CheckButton Widget Syntax 
Python :: xargs in python 
Python :: assignment operators in python 
Python :: python math ln 
Python :: class __call__ method python 
Python :: Python List clear() 
Python :: python numpy how to empty array cycle 
Python :: explain the use of return keyword python 
Python :: convert method to str python 
Python :: graph skewness detection 
Python :: Encrypting a message in Python 
Python :: How can I get the named parameters from a URL using Flask? 
Python :: python named tuples 
Python :: connect and disconnect event on socketio python 
Python :: python count the vowels 
Python :: pytest fixture 
Python :: web scraping with selenium 
Python :: include app in django project 
Python :: convert time python 
Python :: how to limit a command to a role in discord.py 
Python :: string to ascii with python 
Python :: flow of control in python 
Python :: google youtuve api 
Python :: Python NumPy ravel function Syntax 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =