Question: Python program Create a python program that will take a string input from a user to check for the max depth of nested parenthesis given
Python program
Create a python program that will take a string input from a user to check for the max depth of nested parenthesis given within that string. The max depth will be returned as an integer to the user.
Conditions for the string input is to expect the user to input only a mix of integer values, parenthesis ) or ( and operators (+,-,=,/,*) symbols, no error checking is necessary on the programmers` side for these inputs.
Inputs with only parenthesis are also valid such as () () and ()(()()), these inputs would have a maximum nested depth of 1 and 2 respectively, whereas input such as )( and ((() would not be valid and have a depth of zero (as they are not properly nested and closed)
Sample example 1:
User input: (2 (4*4) * ((1)+9))
Output: 3 (the 1 is nested within 3 times)
Sample example 2:
User input: (9*9) + 8/3+(4*4)
Output: 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
