You are viewing a single comment's thread. Return to all comments →
n = int(input()) empty = [] for i in range(n): command = input() if command[0:6] == "insert": empty.insert(int(command[7]),int(command[9])) elif command[0:6] == "remove": empty.remove(int(command[7])) elif command[0:6] == "append": empty.append(int(command[7])) elif command == "pop": if len(empty) != 0: empty.pop() elif command == "sort": empty.sort() elif command == "reverse": empty.reverse() elif command == "print": print(empty)
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 →
n = int(input()) empty = [] for i in range(n): command = input() if command[0:6] == "insert": empty.insert(int(command[7]),int(command[9])) elif command[0:6] == "remove": empty.remove(int(command[7])) elif command[0:6] == "append": empty.append(int(command[7])) elif command == "pop": if len(empty) != 0: empty.pop() elif command == "sort": empty.sort() elif command == "reverse": empty.reverse() elif command == "print": print(empty)