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.
- Prepare
- Python
- Basic Data Types
- Lists
- Discussions
Lists
Lists
Sort by
recency
|
2890 Discussions
|
Please Login in order to post a comment
i create an empty list and added the all commands in the input but only one testcase is passed another testcase 1 is failed may i know the reason
if name == 'main': N = int(input()) cmd_ls = [] data = []
n = int(input()) List = [] for i in range(n): command = input().split() if command[0] == "insert": List.insert(int(command[1]), int(command[2])) elif command[0] == "remove": List.remove(int(command[1])) elif command[0] == "append": List.append(int(command[1])) elif command[0] == "sort": List.sort() elif command[0] == "pop": List.pop() elif command[0] == "reverse": List.reverse() elif command[0] == "print": print(List)