s=list(input())
for i in range(len(s)):
if s[i]!=s[-(i+1)]:
print('不是回文')
break
else:
print('是回文')
涉及代码缩进,贴图。
#判断一个字符串是不是“回文”
def is_palindrome(s):
lists = list(s)
l = list(s)
new_list = []
for i in range(len(lists)):
new_list.append(lists.pop())
if new_list == l:
return True
else:
return False
print(is_palindrome("abcdefgfedcba"))