Write a Python Program to find palindrome of a given string
If you reverse the word then you get the same word that word is palindrome. def palindrome ( str ): pointer = str rev_str = reversed (pointer) if list (pointer) == list (rev_str): print ( "It is palindrome" ) else : print ( "It is not palindrome" ) palindrome( 'level' ) palindrome( 'madam' ) palindrome( 'life' ) palindrome( 'refer' ) Output: It is palindrome It is palindrome It is not palindrome It is palindrome


Comments
Post a Comment