Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

string Palindronme in python

python program to get a String and reverse the characters of the string. And check whether reverse order and original order is same.

Sample Input 1 :

madam

Sample Output 1 :

Palindronme

Program or Solution

					    
							
s1=input("Enter a String:")
s2=""
j=len(s1)-1
while(j>=0):
    s2+=s1[j]
    j-=1
if(s1==s2):
    print("Palindromne")
else:
    print("Not Palindromne")

    
            
            
				

					    
					

Program Explanation

visit each location in string s1 from the last location len(l)-1 and append it to s2. if s1 is equal to s2 then it is palindronme else it is not palindronme.

Note: String is immutable, so you cannot modify a character directly in a orginal string.