İçeriğe atla
Kod Okumaİki Tür Parantez
Kodu Boz

İki Tür Parantez

Bu fonksiyonun yanlış cevap verdiği bir metin yaz.
1def nested(text):
2 round_depth = 0
3 square_depth = 0
4 for ch in text:
5 if ch == "(":
6 round_depth += 1
7 elif ch == ")":
8 round_depth -= 1
9 elif ch == "[":
10 square_depth += 1
11 else:
12 square_depth -= 1
13 if round_depth < 0 or square_depth < 0:
14 return False
15 return round_depth == 0 and square_depth == 0