11def is_palindrome (s : str ) -> bool :
22 """
3- Determine whether the string is palindrome
4- :param s:
5- :return: Boolean
6- >>> is_palindrome("a man a plan a canal panama".replace(" ", ""))
3+ Determine if the string s is a palindrome.
4+
5+ >>> is_palindrome("A man, A plan, A canal -- Panama!")
76 True
87 >>> is_palindrome("Hello")
98 False
@@ -14,15 +13,15 @@ def is_palindrome(s: str) -> bool:
1413 >>> is_palindrome("Mr. Owl ate my metal worm?")
1514 True
1615 """
17- # Since Punctuation , capitalization, and spaces are usually ignored while checking
18- # Palindrome, we first remove them from our string.
19- s = "" .join ([ character for character in s .lower () if character .isalnum ()] )
16+ # Since punctuation , capitalization, and spaces are often ignored while checking
17+ # palindromes, we first remove them from our string.
18+ s = "" .join (character for character in s .lower () if character .isalnum ())
2019 return s == s [::- 1 ]
2120
2221
2322if __name__ == "__main__" :
24- s = input ("Enter string to determine whether its palindrome or not : " ). strip ( )
23+ s = input ("Please enter a string to see if it is a palindrome : " )
2524 if is_palindrome (s ):
26- print ("Given string is palindrome" )
25+ print (f"' { s } ' is a palindrome. " )
2726 else :
28- print ("Given string is not palindrome" )
27+ print (f"' { s } ' is not a palindrome. " )
0 commit comments