Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
564 B
3
Indexable
Never
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)
Leave a Comment