Jeremy Sanders wrote:
> candide wrote:
>
>> I'm trying to implement in Python a function testing if an expression is
>> well parenthesized. For instance the expression "zx4er(1(er(Yy)ol)ol)ik"
>> is correctly parenthesized but this one "zx(4er(1(er(Yy)ol)ol)ik" is not.
>>
>> My code follows at the end.
>>
>> If you have a better algorithm or a better Python code (I'm a beginner in
>> the Python world), don't hesitate ...
>
> Don't you want to just test that the number of "("s equals the number of
> ")"s or am I missing the point?
Yep, you are:
"())))((("
is certainly not "well parenthized".
Diez
--
http://mail.python.org/mailman/listinfo/python-list