Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions