Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago