Answers for "python merge list no duplicates"

-2

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)
Posted by: Guest on March-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language