Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

merge two lists python remove duplicates

first_list = [1, 2, 2, 5]
second_list = [2, 5, 7, 9]

resultList= list(set(first_list) | set(second_list))

print(resultList)
# Results in : resultList = [1,2,5,7,9]
Comment

python merge list no duplicates

# Create the two lists
l1 = [1, 2, 2, 4]
l2 = [2, 5, 5, 5, 6]
# Find elements that are in second but not in first
new = set(l2) - set(l1)
# Create the new list using list concatenation
l = l1 + list(new)
Comment

PREVIOUS NEXT
Code Example
Python :: data encapsulation in python 
Python :: 3d graph python 
Python :: python describe 
Python :: drop columns 
Python :: python singleton module 
Python :: run python code online 
Python :: python using set 
Python :: what is self 
Python :: remove item in dict 
Python :: how to create list in python 
Python :: python pytest vs unittest 
Python :: Python program to find second largest 
Python :: Python NumPy concatenate Function Syntax 
Python :: gui in python 
Python :: split dataframe row on delimiter python 
Python :: python while loop 
Python :: read yml file in python 
Python :: python cast to int 
Python :: image to vector conversion function 
Python :: sys python 
Python :: python program to find sum of array elements 
Python :: unzipping the value using zip() python 
Python :: pydantic numpy ndarray type 
Python :: TypeError: Object of type DictProxy is not JSON serializable 
Python :: Multiple page PyQt QStackedWidget 
Python :: how to print on same line python 
Python :: ytdl python check video length 
Python :: index operator in python without input 
Python :: how to get random images frrom quotefancy python 
Python :: fungsi untuk mengecek apakah ada data yang kosong 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =