forked from dikshitakambri/python_HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 4
/
lists.py
32 lines (31 loc) · 900 Bytes
/
lists.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
28
29
30
31
32
if __name__ == '__main__':
N = int(input())
ar = []
for i in range(0, N):
tmp_str = input()
tmp_str_ar = tmp_str.strip().split(" ")
cmd = tmp_str_ar[0]
if cmd == "print":
print(ar)
elif cmd == "sort":
ar.sort()
elif cmd == "reverse":
ar.reverse()
elif cmd == "pop":
ar.pop()
elif cmd == "count":
val = int(tmp_str_ar[1])
ar.count(val)
elif cmd == "index":
val = int(tmp_str_ar[1])
ar.index(val)
elif cmd == "remove":
val = int(tmp_str_ar[1])
ar.remove(val)
elif cmd == "append":
val = int(tmp_str_ar[1])
ar.append(val)
elif cmd == "insert":
pos = int(tmp_str_ar[1])
val = int(tmp_str_ar[2])
ar.insert(pos, val)