We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 822f945 commit 5709934Copy full SHA for 5709934
python/codewars/valid_parentheses.py
@@ -2,19 +2,19 @@
2
# Write a function that takes a string of parentheses, and determines if the order of the parentheses is valid.
3
4
def valid_parentheses(string):
5
- if (string.count('(') != string.count(')')):
+ if string.count('(') != string.count(')'):
6
return False
7
stack = []
8
for s in string:
9
- if(s == '('):
+ if s == '(':
10
stack.append(s)
11
- elif(s == ')'):
+ elif s == ')':
12
try:
13
stack.pop()
14
except IndexError:
15
16
17
- if(len(stack) == 0):
+ if len(stack) == 0:
18
return True
19
else:
20
0 commit comments