Lists | HACKER RANK

Asked: Rahul Kumar Ranjan |Category: Python

n=int(input())

l=[]

for i in range (n):

x=input().split(" ")

com=x[0]

if com=="insert":

l.insert(int(x[1]),int(x[2]))

elif com=="print":

print(l)

elif com=="remove":

l.remove(int(x[1]))

elif com=="append":

l.append(int(x[1]))

elif com=="sort":

l.sort()

elif com=="pop":

if len(l)!=0:

l.pop()

elif com=="reverse":

l.reverse()


46 views

Recent Posts

See All

"Believe you can and you're halfway there"