- Get link
- X
- Other Apps
Given two Python sets, update the first set with items that exist only in the first set and not in the second set in Python
- Get link
- X
- Other Apps
set1 = {10, 20, 30}
set2 = {20, 40, 50}
Expected output:
set1 {10, 30}
Code :
set1 = {10, 20, 30}
set2 = {20, 40, 50}
set1.difference_update(set2)
print(set1)
Comments
Post a Comment