Question Source
Python Java
Code :
# Write code to check a String is palindrome or not?I had used string slicing to reverse the String. Slice the string backwards by using the step value -1, to get it in reverse order.
def reverse(string):
rev = string[::-1]
if string == rev:
print("String is palindrome")
else:
print("String is not a palindrome")
text = input("Enter a string : ")
reverse(text)
Output :
when the String entered is abc
Enter a string : abc
String is not a palindrome
when the String entered is aba
Enter a string : aba
String is palindrome
0 Comments
Ask Your Queries in the comments