File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ def is_string_palindrome (words : str ) -> bool :
2
+ """
3
+ Returns whether `num` is a palindrome or not
4
+ (see for reference https://en.wikipedia.org/wiki/Palindromic_number).
5
+
6
+ >>> is_string_palindrome("-121")
7
+ False
8
+ >>> is_string_palindrome("0")
9
+ True
10
+ >>> is_string_palindrome("10")
11
+ False
12
+ >>> is_string_palindrome("11")
13
+ True
14
+ >>> is_string_palindrome("101")
15
+ True
16
+ >>> is_string_palindrome("120")
17
+ False
18
+ >>> is_string_palindrome(120)
19
+ False
20
+ >>> is_string_palindrome("madam")
21
+ True
22
+ >>> is_string_palindrome("racecar")
23
+ True
24
+ >>> is_string_palindrome("hello")
25
+ False
26
+ >>> is_string_palindrome("A man a plan a canal Panama")
27
+ True
28
+ >>> is_string_palindrome(120)
29
+ False
30
+ >>> is_string_palindrome("")
31
+ True
32
+ >>> is_string_palindrome("noon")
33
+ True
34
+ >>> is_string_palindrome("Was it a car or a cat I saw")
35
+ True
36
+ >>> is_string_palindrome("Python")
37
+ False
38
+ >>> is_string_palindrome(" ")
39
+ True
40
+ """
41
+ cleaned_phrase = '' .join (words .split ()).lower ()
42
+ return cleaned_phrase == cleaned_phrase [::- 1 ]
43
+
44
+ if __name__ == "__main__" :
45
+ n = input ("Enter a word:-" )
46
+ print (is_string_palindrome (n ))
You can’t perform that action at this time.
0 commit comments