A palindrome is a string that reads the same backward as forward. For example, the words dad, madam and radar are all palindromes. Write a programs that determines whether the string is a palindrome.

Note: do not use reverse() method

Source Code

#1

text = input('Enter a string: ')
length = len(text)

flag = True

for i in range(0,length//2):
    if text[i] != text[length-1-i]:
        flag = False
        break

if flag == True:
    print('String is palindrome')
else:
    print('String is not palindome')

#2

text = input('Enter a string: ')
#reverse string
newtext = text[::-1]

if text == newtext:
    print('String is palindrome')
else:
    print('String is not palindrome')

Output

Enter a string: madam
String is palindrome