Reverse a string and calculate unchanged positions to the original string?
str1=input("Enter a string: ")
str2=str1[::-1]
print(str1,str2)
count=0
for i in range(len(str1)):
if(str1[i]==str2[i]):
count+=1
print("Number of unchanged positions to the original string = ",count)
Comments
Leave a comment