Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

# find the common elements in the list.

# find the common elements in the list.
l1 = ['a','b','c','d','e','f','g','h','a','b']
l2 = ['e','f','g','h','i','j']
s1=set(l1).intersection(l2)
print(list(s1))

#['g', 'f', 'e', 'h']
Comment

find common in lists

>>> a = [1, 2, 3, 4]
>>> b = [2, 3, 4, 5]
>>> c = [3, 4, 5, 6]
>>> set(a) & set(b) & set(c)
{3, 4}
Comment

PREVIOUS NEXT
Code Example
Python :: export a dataframe from rstudio as csv 
Python :: python tkinter filedialog 
Python :: how to make a pygame window 
Python :: create list in range 
Python :: emacs region indent python 
Python :: reject invalid input using a loop in python 
Python :: change the style of notebook tkinter 
Python :: python check string float 
Python :: python conditional assignment 
Python :: where to find python interpreter 
Python :: python requests get cookies 
Python :: flask define template folder 
Python :: hide particular attribute in django admin 
Python :: python n choose r 
Python :: pyspark select without column 
Python :: leaky relu keras 
Python :: python command not found 
Python :: pandas groupby aggregate quantile 
Python :: jupyter themes 
Python :: python replace multiple spacis with spaces 
Python :: pygame event mouse right click 
Python :: time date in pandas to csv file 
Python :: pil image shape 
Python :: Scrape the text of all paragraph in python 
Python :: random forrest plotting feature importance function 
Python :: how to make a never ending loop in python 
Python :: python delete the last line of console 
Python :: create np nan array 
Python :: python watchgod 
Python :: import counter python 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =