Skip to content

Commit 8f34eff

Browse files
Create Set Mutations.py
1 parent fea14a8 commit 8f34eff

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Challenges/Sets/Set Mutations.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)