0% found this document useful (0 votes)
43 views2 pages

Class Palindrome Python

This document contains code for checking if a given word is a palindrome using different approaches - recursively checking the first and last characters, reversing the string and comparing, and defining a Palindrome class with a static method to check palindromes. It takes user input, calls the checking method and prints the output.

Uploaded by

Eua Drand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Class Palindrome Python

This document contains code for checking if a given word is a palindrome using different approaches - recursively checking the first and last characters, reversing the string and comparing, and defining a Palindrome class with a static method to check palindromes. It takes user input, calls the checking method and prints the output.

Uploaded by

Eua Drand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

class Palindrome:

@staticmethod

def is_palindrome(word):

#Please write your code here.

return None

word = input()

print(Palindrome.is_palindrome(word))

class Palindrome:

@staticmethod

def is_palindrome(word):

if len(word) <= 1:

return True

else:

if word[0] != word[len(word)-1]:

return False

else:

return is_palindrome(word[1:len(word)-1])

return None

word = input()

print(Palindrome.is_palindrome(word))

ΣΩΣΤΟ

word = input()

x = ''.join(reversed(word))

if word == x:

print('TRUE')
else:

print('false')

print(''.join(reversed(word)))

SOSTO ME CLASS

class Palindrome:

@staticmethod

def is_palindrome(word):

x = ''.join(reversed(word))

if(x == word):

return True

else:

return False

word = input()

print(Palindrome.is_palindrome(word))

You might also like