summaryrefslogtreecommitdiff
path: root/python/parentesi.py
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-05-04 15:17:35 +0200
committerSanto Cariotti <sancn@live.com>2017-05-04 15:17:35 +0200
commit64ca40e3a2f77adb872900d386b6bfeaf3583960 (patch)
tree876aab42b498ad8d09bd8716d585cf614fb25ce2 /python/parentesi.py
parent1fe81696147012e9023491a40b6ad645adbc0630 (diff)
Modified some files
Diffstat (limited to 'python/parentesi.py')
-rw-r--r--python/parentesi.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/python/parentesi.py b/python/parentesi.py
index a89e046..e4967a9 100644
--- a/python/parentesi.py
+++ b/python/parentesi.py
@@ -12,21 +12,21 @@ t = q = g = 0
tot = 0
-for i in range(len(stringa)):
- if stringa[i] == '(':
+for i in stringa:
+ if i == '(':
t += 1
- elif stringa[i] == '[':
+ elif i == '[':
q += 1
- elif stringa[i] == '{':
+ elif i == '{':
g += 1
- if stringa[i] == ')' and t > 0:
+ if i == ')' and t > 0:
t -= 1
tot += 1
- elif stringa[i] == ']' and q > 0:
+ elif i == ']' and q > 0:
q -= 1
tot += 1
- elif stringa[i] == '}' and g > 0:
+ elif i == '}' and g > 0:
g -= 1
tot += 1