-
Notifications
You must be signed in to change notification settings - Fork 230
/
Lists.py
35 lines (33 loc) · 927 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
33
34
35
"""
Title : Lists
Subdomain : Data Types
Domain : Python
Author : Ahmedur Rahman Shovon
Created : 06 July 2020
Updated : 06 February 2023
Problem : https://www.hackerrank.com/challenges/python-lists/problem
"""
if __name__ == "__main__":
N = int(input())
ar = []
for _ in range(N):
command_args = input().strip().split(" ")
cmd = command_args[0]
if cmd == "print":
print(ar)
elif cmd == "sort":
ar.sort()
elif cmd == "reverse":
ar.reverse()
elif cmd == "pop":
ar.pop()
elif cmd == "remove":
val = int(command_args[1])
ar.remove(val)
elif cmd == "append":
val = int(command_args[1])
ar.append(val)
elif cmd == "insert":
pos = int(command_args[1])
val = int(command_args[2])
ar.insert(pos, val)