mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-17 14:58:10 +00:00
Fixed bug where an empty stack would cause error
This commit is contained in:
parent
a8cfc14737
commit
2e2fadf4db
|
@ -12,8 +12,10 @@ def balanced_parentheses(parentheses):
|
|||
if parenthesis == '(':
|
||||
stack.push(parenthesis)
|
||||
elif parenthesis == ')':
|
||||
if stack.is_empty():
|
||||
return False
|
||||
stack.pop()
|
||||
return not stack.is_empty()
|
||||
return stack.is_empty()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue
Block a user