Below are the ideal outputs:
'''
>>> palindrome = Palindrome('eye')
>>> palindrome.original_text
'eye'
>>> palindrome.reversed_text
'eye'
>>> palindrome.is_palindrome()
True
>>> palindrome = Palindrome('dye')
>>> palindrome.original_text
'dye'
>>> palindrome.reversed_text
'eyd'
>>> palindrome.is_palindrome()
False
'''
My code:
class Palindrome :
def __init__(self,number) :
self.num = number
def is_palindrome(self) :
temp = self.num
result = 0
while(temp != 0) :
rem = temp % 10
result = result * 10 + rem
temp //= 10
if self.num == result :
return True
else :
return False
How to add this both original_text and reversed_text attributes in this class? How should I fix the code above to obtain the ideal results?