We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Sets
- Set Mutations
- Discussions
Set Mutations
Set Mutations
Sort by
recency
|
772 Discussions
|
Please Login in order to post a comment
n = int(input()) A = set(input().split()) for _ in range(int(input())): l1 = list(input().split()) s2 = set(input().split()) st = l1[0] eval(f'A.{st}(s2)') print(sum(map(int,A)))
n = int(input()) A = set(map(int, input().split()))
S = int(input())
for i in range(S): Choice = input().split() N = set(map(int, input().split())) if Choice[0] == "intersection_update": A.intersection_update(N) elif Choice[0] == "update": A.update(N) elif Choice[0] == "symmetric_difference_update": A.symmetric_difference_update(N) elif Choice[0] == "difference_update": A.difference_update(N)
print(sum(A))