#判断回文联 上海自来水来自海上
def judgesentence(sentence):
lenth=len(sentence)
for each in range(lenth):
if sentence[each]==sentence[-(each+1)]:
q=True
else:
q=False
return q
sentence=input('请输入:')
if judgesentence(sentence):
print('是回文联')
else:
print('不是回文联')
#方法二
def palindrome(string):
list1 = list(string)
list2 = reversed(list1)
if list1 == list(list2):
return '是回文联!'
else:
return '不是回文联!'
print(palindrome('上海自来水来自海上'))