-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist operations
More file actions
61 lines (38 loc) · 890 Bytes
/
Copy pathlist operations
File metadata and controls
61 lines (38 loc) · 890 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
50
51
52
53
54
55
56
57
58
59
Sample Input 0
# 12
# insert 0 5
# insert 1 10
# insert 0 6
# print
# remove 6
# append 9
# append 1
# sort
# print
# pop
# reverse
# print
# Sample Output 0
# [6, 5, 10]
# [1, 5, 9, 10]
# [9, 5, 1]
if __name__ == '__main__':
N = int(input())
list1=[]
while N >0:
command,*pos=input().split()
if command=='insert':
list1.insert(int(pos[0]),int(pos[1]))
if command=='remove':
list1.remove(int(pos[0]))
if command=='print':
print(list1)
if command=='append':
list1.append((int(pos[0])))
if command=='sort':
list1.sort()
if command=='pop':
list1.pop()
if command=='reverse':
list1.reverse()
N-=1