
Given a word, print Yes if it is a palindrome, otherwise No.
A palindrome is a word which reads the same backward as forward, e.g. racecar.
Input
The input will contain a string S (0 < Length of S <100 ).
S will contain lowercase alphabets only.
Output
Print Yes or No.
Show which are palindrome or not palindrome
Samples
Input | Output |
racecar | Yes |
Input | Output |
carrot | No |
Solution
Python
# -*- coding: utf-8 -*-
# a=list(input())
a = "eye"
b = a[::-1] # reverses a list
c = ",".join(b) # seperator.join(type)
d = c.replace(",", "") # from.replace("this","to this")
if a == d:
print("Yes")
else:
print("No")
C++
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string st,re;
cin>>st;
re=st;
reverse(re.begin(),re.end());
if(st==re)
{
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
return 0;
}
C
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,r;
cin>>s;
r=s;
reverse(r.begin(),r.end());
if(r==s)
printf("Yes\n");
else
printf("No\n");
return 0;
}
You must belogged in to post a comment.