Question: Python please Question 6 Consider a string that contains a pair of matching parentheses with zero or more characters between the parentheses. Examples of such

Python please

Python please Question 6 Consider a string that contains a pair of

Question 6 Consider a string that contains a pair of matching parentheses with zero or more characters between the parentheses. Examples of such strings include: * abcd)eg' The professor and her research assistant) solved an important problem.' X + ((y + 2)/2) 10 Notice that the last example string contains a pair of nested parentheses. Write a recursive function set_enclosed(s) that returns the part of the strings that is enclosed by the outermost pair of matching parentheses including the parentheses. For each of the example strings shown above your function should return the following strings: (bxed) (and her research assistant) (y + 2) / 2) Your function does not need handle strings where there are two or more pairs of matching parentheses that are not nested. Examples of such input strings that you can ignore are: (**-*)(***)' a/bed) (efghijklm)' (x + y) + (y + 2) Finally, if the string does not contain a matching pair of parentheses then your function should return the empty string ' . Examples of such input strings include: * ) abcdefghi abcdefgh You may use the string methods startewith and endswith, but your function should not use any other string methods (such as find or lodex )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!