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
Get step-by-step solutions from verified subject matter experts
