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
|
809 Discussions
|
Please Login in order to post a comment
Here's my code:
A = int(input()) el_A = set(map(int, input().split())) for i in range(int(input())): command = input().split() set_b = set(map(int, input().split())) if command[0] == 'update': el_A.update(set_b) elif command[0] == 'intersection_update': el_A.intersection_update(set_b) elif command[0] == 'difference_update': el_A.difference_update(set_b) elif command[0] == 'symmetric_difference_update': el_A.symmetric_difference_update(set_b) print(sum(el_A))