-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists_operations.py
More file actions
44 lines (40 loc) · 843 Bytes
/
Lists_operations.py
File metadata and controls
44 lines (40 loc) · 843 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
if __name__ == '__main__':
N = int(input())
x = []
for i in range(N):
query, *others = input().split()
if query == 'insert':
position,value = map(int,others)
x.insert(position,value)
elif query == 'print':
print(x)
elif query == 'remove':
values_1 = list(map(int, others))
x.remove(values_1[0])
elif query == 'append':
values_2 = list(map(int, others))
x.append(values_2[0])
elif query == 'pop':
x.pop()
elif query == 'sort':
x.sort()
elif query == 'reverse':
x.reverse()
'''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]'''