Question: The string method `.startswith(pattern)` consumes a pattern (a string) and returns a boolean indicating whether that pattern appears at the start of the original string.

The string method `.startswith(pattern)` consumes a pattern (a string) and returns a boolean indicating whether that pattern appears at the start of the original string. The string method `.endswith(pattern)` consumes a pattern (a string) and returns a boolean indicating whether that pattern appears at the end of the original string. Use these methods to implement a new function named is_surrounded that consumes a sentence (a string) and returns a boolean indicating whether the sentence has parentheses on both sides. In other words, the string begins with "(" and ends with ")". You encouraged, but not required, to unit test your function.

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!