Source Code:
(back to article)
# Removing duplicate elements from a list using a set my_list = [1, 2, 2, 3, 4, 4, 5] my_set = set(my_list) unique_list = list(my_set) print(unique_list) # Finding the common elements between two sets set1 = {1, 2, 3} set2 = {3, 4, 5} common_set = set1.intersection(set2) print(common_set)
Result:
Report an issue