-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_methods.py
More file actions
33 lines (31 loc) · 794 Bytes
/
set_methods.py
File metadata and controls
33 lines (31 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
n = int(input())
s = set(map(int, input().split()))
N = int(input())
for testcases in range(N):
commands = input().split(' ')
if commands[0] == "pop":
if len(commands)== 1:
s.pop()
elif len(commands) == 2:
try:
commands[1] = int(commands[1])
s.pop(commands[1])
except:
pass
else:
pass
elif commands[0] == "remove":
try:
commands[1] = int(commands[1])
s.remove(commands[1])
except:
pass
elif commands[0] == "discard":
try:
commands[1] = int(commands[1])
s.discard(commands[1])
except:
pass
else:
print("wrong commands")
print(sum(s))