We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if name == 'main':
lst = []
N = int(input())
for i in range(N):
cho = input().lower()
ch = cho.split()
match ch[0]:
case "insert":
lst.insert(int(ch[1]), int(ch[2]))
case "print":
print(lst)
case "remove":
lst.remove(int(ch[1]))
case "append":
lst.append(int(ch[1]))
case "sort":
lst.sort()
case "pop":
lst.pop()
case "reverse":
lst.reverse()
case _:
print("INVALID CHOICE!")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lists
You are viewing a single comment's thread. Return to all comments →
if name == 'main': lst = [] N = int(input()) for i in range(N): cho = input().lower() ch = cho.split() match ch[0]: case "insert": lst.insert(int(ch[1]), int(ch[2])) case "print": print(lst) case "remove": lst.remove(int(ch[1])) case "append": lst.append(int(ch[1])) case "sort": lst.sort() case "pop": lst.pop() case "reverse": lst.reverse() case _: print("INVALID CHOICE!")