marcosthomazs

Detectando Tokens

Jan 26th, 2021
990
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def recebe_seq(vetor):
  2.     aux = []
  3.     tokens = {']': '[', '}': '{', ')': '('}
  4.     for i in vetor:
  5.         if i in tokens.values():
  6.             aux.append(i)
  7.         else:
  8.             if len(aux) == 0 or tokens[i] != aux[-1]:
  9.                 return False
  10.             aux = aux[:-1]
  11.     return len(aux) == 0
  12.  
RAW Paste Data