Python program to check if the given string is palindrome or not
Check if the given string is palindrome or not
A string is said to be palindrome if the reverse of the string also remains the same and if the original string gives some meaning so the meaning of the reversed string should also remain the same. Ex.:- MaaM is a palindrome string if we read it in the order it is given it remains the same even if we reverse it and meaning also remains the same.
In this python program, we will check whether the given string is palindrome or not.
- Step 1:- Start.
- Step 2:- Take user input.
- Step 3:- Initialize a string and store reverse of 1st string in it.
- Step 4:- Check if Both the strings matches by using == operator.
- Step 5:- If TRUE print string is palindrome.
- Step 6:- Else print string is not palindrome.
- Step 7:- End.
Python program to check if the string is palindromic or not
#take user input String1 = input('Enter the String :') #initialize string and save reverse of 1st string String2 = String1[::-1] #check if both matches if String1 == String2: print('String is palindromic') else: print('Strings is not palindromic')
Enter the String :sagas
String is palindromic