Sometimes, in coding challenges, you will be asked to count the number of valid possible parentheses. You need to tweak a couple of lines of code. Instead of printing balanced parenthesis, use out as a counter.

I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.