String Symmetry Check
EasyPractice library · +10 XPstringsloopsconditionals
Given a string S, determine if it reads the same forwards and backwards. Such a string is called a palindrome. For example, "madam" is a palindrome, but "hello" is not. Your task is to check if the given string is a palindrome.
Input
A single line containing the string S. S consists of lowercase English letters.
Output
Print "YES" if S is a palindrome, and "NO" otherwise.
Constraints
1 <= length of S <= 1000
Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests
Example 1
Input
madam
Output
YES
Reads the same forwards and backwards.
Example 2
Input
hello
Output
NO
Reads "olleh" backwards, which is different.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
madam
Example 2 input
hello