Advertisement
Guest User

listas_python

a guest
Apr 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. def lista_operacoes(lista, *args):
  2.        
  3.     if args[0] == 'insert':
  4.         lista.insert(int(args[1]), int(args[2]))
  5.     elif args[0] == 'print':
  6.         print(lista)
  7.     elif args[0] == 'remove':
  8.         lista.remove(int(args[1]))
  9.     elif args[0] == 'append':
  10.         lista.append(int(args[1]))
  11.     elif args[0] == 'sort':
  12.         lista = lista.sort()
  13.     elif args[0] == 'pop':
  14.         lista.pop()
  15.     elif args[0] == 'reverse':
  16.         lista = lista.reverse()
  17.    
  18. if __name__ == '__main__':
  19.     N = int(input())
  20.     lista = []
  21.     for _, _ in enumerate(range(N)):
  22.         entradas = input().split()
  23.         lista_operacoes(lista, *entradas)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement