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
|
2846 Discussions
|
Please Login in order to post a comment
if name == 'main': N = int(input()) my_list=[] for _ in range(N): action=input().split() match action: case ["append", x]: my_list.append(int(x)) case ["insert",x,y]: my_list.insert(int(x),int(y)) case ["print"]: print(my_list) case ["remove",e]: my_list.remove(int(e)) case ["sort"]: my_list.sort() case ["pop"]: my_list.pop() case ["reverse"]: my_list.reverse()
`if name == "main": N = int(input())
if name == 'main': N = int(input()) # Number of commands my_list = [] # Initialize empty list