Question: Your task is to write a routine: find _ palindrome ( pattern ) which takes a tuple and returns a tuple or None. The returned

Your task is to write a routine: find_palindrome(pattern) which takes a tuple and returns a tuple or None.
The returned tuple must be a palindrome which results from removing just one element from pattern. So, for instance, if pattern was (3,2,1,1,2,4,3), the returned tuple would be (3,2,1,1,2,3). If more than one element must be removed from the tuple to make a palindrome, or a palindrome is not possible, then find_palindrome() returns None.
A few special cases:
No trivial (single element) palindromes. The returned palindrome must be of length 2 or longer. If pattern is too short to result in a palindrome of length 2 or pattern is None, return None.
No throwing exceptions (they confuse zybooks). If there are other bad input conditions not discussed here, return None.
No modifying elements in pattern. So if pattern is ("ab","a","a"), do not return ("a","a","a").
No moving elements within pattern. The only permissible change to get a new pattern is to remove one element.
pattern may already be a palindrome, in which case you need to see if a there is a way to remove one element and get a new palindrome.

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 Programming Questions!