From 64ca40e3a2f77adb872900d386b6bfeaf3583960 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 4 May 2017 15:17:35 +0200 Subject: Modified some files --- python/parentesi.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'python/parentesi.py') 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 -- cgit v1.2.3-18-g5258