You are viewing a single comment's thread. Return to all comments →
if __name__ == '__main__': N = int(input()) instructionList = [input().split() for i in range(N)] finalArray = [] for instruction in instructionList: length = len(instruction) if length == 1: currentInstruction = instruction[0] elif length == 2: currentInstruction = instruction[0] e = int(instruction[1]) elif length == 3: currentInstruction = instruction[0] i = int(instruction[1]) e = int(instruction[2]) match currentInstruction: case "insert": finalArray.insert(i, e) case "print": print(finalArray) case "remove": finalArray.remove(e) case "append": finalArray.append(e) case "sort": finalArray.sort() case "pop": finalArray.pop() case "reverse": finalArray.reverse()
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 →