top of page
Click here to go to the home page of AskTheCode.

Lists | HACKER RANK

Team ATC

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()


Recent Posts

See All

Comments

Couldn’t Load Comments
It looks like there was a technical problem. Try reconnecting or refreshing the page.
bottom of page