list hackerrank solution

Solutions on MaxInterview for list hackerrank solution by the best coders in the world

showing results for - "list hackerrank solution"
Yassin
24 Feb 2020
1list=[]
2n=int(input())
3for i in range(n):  
4    p=input().split()
5    if p[0]=="insert":
6        list.insert(int(p[1]),int(p[2]))
7    elif p[0]=="print":
8        print(list)
9    
10    elif (p[0]=="remove"):
11        list.remove(int(p[1]))
12    elif p[0]=="append":
13        list.append(int(p[1]))
14    elif p[0]=="sort":
15        list.sort()
16    elif p[0]=="print":
17        print(list)
18    elif p[0]=="pop":
19        list.pop()
20    elif p[0]=="reverse":
21        list.reverse()
22    elif p[0]=="print":
23        print(list)
24  
25
26      
27
28