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
|
2901 Discussions
|
Please Login in order to post a comment
For Python3 Platform
if name == 'main': N = int(input()) # number of commands lst = [] # initialize empty list
if name == 'main': N = int(input()) fin=[] for i in range(N): value=input() value=value.split() if value[0]=='insert': fin.insert(int(value[1]),int(value[2])) if value[0]=='print': print(fin) if value[0]=='remove': fin.remove(int(value[1])) if value[0]=='sort': fin.sort() if value[0]=='reverse': fin.reverse() if value[0]=='pop': fin.pop() if value[0]=='append': fin.append(int(value[1]))