I have been trying to solve the problem using a method which does not work. Trying to find the issues I haven’t found anything.
def is_balanced_parentheses(string):
is_balanced = True
balanced = Stack()
for i in string:
if i == "(":
balanced.push(i)
if i == ")":
balanced.push(i)
if balanced.stack_list[0] == ")":
is_balanced = False
elif balanced.stack_list[0] == "(":
is_balanced = True
return is_balanced
New contributor
José Miguel Santos Roldán is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5