-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists.py
More file actions
24 lines (22 loc) · 716 Bytes
/
Lists.py
File metadata and controls
24 lines (22 loc) · 716 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
# Question link - https://www.hackerrank.com/challenges/python-lists/problem?isFullScreen=true
if __name__ == '__main__':
N = int(input())
arr = []
for i in range(N):
cmd = input().split()
if cmd[0] == "insert":
arr.insert(int(cmd[1]),int(cmd[2]))
elif cmd[0] == "print":
print(arr)
elif cmd[0] == "remove":
value = int(cmd[1])
if value in arr:
arr.remove(value)
elif cmd[0] == "append":
arr.append(int(cmd[1]))
elif cmd[0] == "sort":
arr.sort()
elif cmd[0] == "pop":
arr.pop()
elif cmd[0] == "reverse":
arr.reverse()