0
Help in this code
This is the last lesson of data structures course and when run i have two cases wrong (that are not shown ) the objective is print true or False if fhe input expression is parentheses equilibrated. this is my code: def balanced(expression): #tu código va aqu par=[] for i in expression: if i== "(": par.insert(0,"(") elif i==")": if par[0]=="(": par.pop(0) else: return("False") break if par==[]: return("True") else: return("False") print(balanced(input()))
1 Resposta
0
When list is empty and you encounter ')' from input then par[0]=='(' raise error because list is empty...