Question: Python code! Write a function, palindromes, which takes a string as input and returns a list of the unique palindromes that appear in the input

Python code!

Write a function, palindromes, which takes a string as input and returns a list of the unique palindromes that appear in the input string. You may assume that the input string doesnt have any space characters and all characters are lowercase. The strings in the output should be sorted alphabetically. (Palindrome is a string that reads the same backward as forward, e.g., madam or kayak).

palindromes ('cabbbaccab') returns ['abbba', 'acca', 'baccab', 'bb', 'bbb', 'cabbbac', 'cc']

palindromes (' bacdcabdbacdc') returns ['abdba', 'acdca', 'bacdcab', 'bdb', 'cabdbac', 'cdc', 'cdcabdbacdc', 'dcabdbacd']

palindromes (' myracecars') returns ['aceca', 'cec', 'racecar']

You can start with the following code:

def palindromes(S): #write your code here

def testPalindromes (): #write your code here; see the sample test function on page#4

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!