-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11723.py
More file actions
49 lines (43 loc) · 974 Bytes
/
11723.py
File metadata and controls
49 lines (43 loc) · 974 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#20250719
#11723 집합
#구현
from operator import truediv
n=int(input())
a=[]
def check(a,n):
if n in a:
return True
else:
return False
def add(a,n):
if check(a,n):
return
else:
a.append(n)
def remove(a,n):
if check(a,n):
a.remove(n)
else:
return
def toggle(a,n):
if check(a,n):
remove(a,n)
else:
add(a,n)
for _ in range(n):
command = input().split()
operation = command[0]
#operation, operand=input().split()
#실수: operand가 없는 명령도 고려해야함
if operation == 'add':
add(a, int(command[1]))
elif operation == 'remove':
remove(a, int(command[1]))
elif operation == 'check':
print(1 if check(a, int(command[1])) else 0)
elif operation == 'toggle':
toggle(a, int(command[1]))
elif operation == 'all':
a = [i for i in range(1, 21)]
elif operation == 'empty':
a = []