def controle(E): o, f = 0, 0 for i in E: if i == '(': o += 1 if i == ')': f += 1 return o == f