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.
Set .discard(), .remove() & .pop()
Set .discard(), .remove() & .pop()
Sort by
recency
|
1021 Discussions
|
Please Login in order to post a comment
For pypy3
n = int(input()) s = set(map(int, input().split()))
n_2 = int(input())
for i in range(n_2): string = input() try: if "remove" in string or "discard" in string: command, value = string.split() value = int(value) if command == "remove": s.remove(value) elif command == "discard": s.discard(value)
print(sum(s))
Use Python3 instead of pypy3 to get this correct
Here's my code: