Combine Two Lists in Python With Unique Values

(Last Updated On: 02/02/2023)

Python Program to Combine Two Lists With Unique Values

#Python Program to Combine Two Lists With Unique Values

list_1 = [1, 'a']
list_2 = [1, 2, 3, 4, 5]

# If you want the unique items from a concatenated list, you can use list() and set(). 
# set() selects the unique values and list() converts the set into list.
list_joined = list(set(list_1 + list_2))
print(list_joined)

Output:

[1, 2, 3, 4, 5, 'a']

Leave a Reply

Your email address will not be published. Required fields are marked *