Editorial for Palindromes
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Iterate through the string from start to finish. With the index $i$, check that the character at i is equal to the character at length - (i + 1).
Python
in = str(input())
flag = True
for i, c in enumerate(in):
if c != in[len(in) - (i + 1)]:
flag = False
break
print("YES" if flag else "NO")
Comments