This script defines a class CascadingPalindrome
that helps you find the longest cascading palindrome within a given input string. A cascading palindrome is a sequence of words that forms a palindrome when read consecutively.
The CascadingPalindrome
class contains methods to check for palindromes and find the longest cascading palindrome in an input string. The main()
function is the entry point of the script, which takes user input, validates it, and then displays the result.
- Run the script by executing it in a Python environment:
python cascading_palindrome.py
$ python cascading_palindrome.py
Enter the input string: racecar wow anna sees radar
The cascading palindrome is: racecar wow anna sees
$ python cascading_palindrome.py
Enter the input string: hello world python cascading
There is no cascading palindrome in the input string.