Add u7 is_paired.py task
This commit is contained in:
parent
2ba988445a
commit
6e798c47e4
14
u7/is_paired.py
Normal file
14
u7/is_paired.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
def is_paired(input_string):
|
||||||
|
duzki = {
|
||||||
|
')': '(',
|
||||||
|
']': '[',
|
||||||
|
'}': '{'
|
||||||
|
}
|
||||||
|
zbirac = []
|
||||||
|
for simbol in input_string:
|
||||||
|
if simbol in duzki.values():
|
||||||
|
zbirac.append(simbol)
|
||||||
|
elif simbol in duzki:
|
||||||
|
if not zbirac or zbirac.pop() != duzki[simbol]:
|
||||||
|
return False
|
||||||
|
return len(zbirac) == 0
|
||||||
Loading…
Reference in New Issue
Block a user