We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fea14a8 commit 8f34effCopy full SHA for 8f34eff
Challenges/Sets/Set Mutations.py
@@ -0,0 +1,16 @@
1
+if __name__ == '__main__':
2
+ num_A = int(input())
3
+ Set_A = set(map(int, input().split()))
4
+ num_others = int(input())
5
+ for i in range(num_others):
6
+ inp_split = input().split()
7
+ other_set = set(map(int, input().split()))
8
+ if inp_split[0] == 'intersection_update':
9
+ Set_A.intersection_update(other_set)
10
+ elif inp_split[0] == 'update':
11
+ Set_A.update(other_set)
12
+ elif inp_split[0] == 'symmetric_difference_update':
13
+ Set_A.symmetric_difference_update(other_set)
14
+ elif inp_split[0] == 'difference_update':
15
+ Set_A.difference_update(other_set)
16
+ print(sum(Set_A))
0 commit comments