Untitled
unknown
plain_text
2 years ago
564 B
12
Indexable
sample_list = ["Blue", "Green", "Red"]
sample_set = {"Yellow", "Orange", "Black"}
sample_set.update(sample_list)
print(sample_set)
set1 = {10, 20, 30, 40, 50}
set2 = {30, 40, 50, 60, 70}
# Set of identical items
identical_items = set1.intersection(set2)
# Set of unique items from both sets
unique_items = set1.union(set2)
print("Identical items:", identical_items)
print("Unique items:", unique_items)
set1 = {10, 20, 30, 40, 50}
set2 = {30, 40, 50, 60, 70}
set1.intersection_update(set2)
print("Set1 after removing items not common to both sets:", set1)Editor is loading...
Leave a Comment