-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheck Palindrome.py
36 lines (31 loc) · 1012 Bytes
/
Check Palindrome.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
Problem statement
Given a string, determine if it is a palindrome, considering only alphanumeric characters.
Palindrome
A palindrome is a word, number, phrase, or other sequences of characters which read the same backwards and forwards.
Example:
If the input string happens to be, "malayalam" then as we see that this word can be read the same as forward and backwards, it is said to be a valid palindrome.
The expected output for this example will print, 'true'.
From that being said, you are required to return a boolean value from the function that has been asked to implement.
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
0 <= N <= 10^6
Where N is the length of the input string.
Time Limit: 1 second
Sample Input 1 :
abcdcba
Sample Output 1 :
true
Sample Input 2:
coding
Sample Output 2:
false
'''
# Read input as sepcified in the question
st = input()
# Print output as specified in the question
rev = st[::-1]
if rev == st:
print("true")
else:
print("false")