-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList Operations.py
27 lines (27 loc) · 928 Bytes
/
List Operations.py
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
if __name__ == '__main__':
test = cmd_list = list()
command = ''
N = int(input())
for _ in range(N):
command = str(input())
if 'insert' in command:
cmd_list.clear()
cmd_list = list(map(str, command.rstrip().split()))
test.insert(int(cmd_list[1]),int(cmd_list[2]))
elif 'print' in command:
cmd_list.clear()
print(test)
elif 'append' in command:
cmd_list.clear()
cmd_list = list(map(str, command.rstrip().split()))
test.append(int(cmd_list[1]))
elif 'remove' in command:
cmd_list.clear()
cmd_list = list(map(str, command.rstrip().split()))
test.remove(int(cmd_list[1]))
elif 'pop' in command:
test.pop()
elif 'sort' in command:
test.sort()
elif 'reverse' in command:
test.reverse()