Advertisement
Guest User

Lists

a guest
Feb 19th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. if __name__ == '__main__':
  2.     N = int(input())
  3.     list = []
  4.     for n in range(N):
  5.         x = input().split( )
  6.         command = x[0]
  7.         if command == 'insert':
  8.             list.insert(int(x[1]), int(x[2]))
  9.         if command == 'print':
  10.             print(list)
  11.         if command == 'remove':
  12.             list.remove(int(x[1]))
  13.         if command == 'append':
  14.             list.append(int(x[1]))
  15.         if command == 'sort':
  16.             list = sorted(list)
  17.         if command == 'pop':
  18.             list.pop()  
  19.         if command == 'reverse':
  20.             list = list[::-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement