24 lines
653 B
Python
24 lines
653 B
Python
class Phrase:
|
|
"""A class to represent phrases."""
|
|
|
|
def __init__(self, content):
|
|
self.content = content
|
|
|
|
def ispalindrome(self):
|
|
"""Return True for a palindrome, False otherwise."""
|
|
return self.processed_content() == reverse(self.processed_content())
|
|
|
|
def processed_content(self):
|
|
return self.content.lower()
|
|
|
|
class TranslatedPhrase(Phrase):
|
|
"""A class to represent phrases with translation."""
|
|
|
|
def __init__(self, content, translation):
|
|
super().__init__(content)
|
|
self.translation = translation
|
|
|
|
def reverse(string):
|
|
"""Reverse a string."""
|
|
return "".join(reversed(string))
|