标签:lse ext ever reverse 方法 lin abc range false
回文正序和逆序一样的字符串,例如abccba
def is_palindrome1(text):
l = list(text)
l.reverse()
t1 = ‘‘.join(l)
if t1 == text:
print ‘the text is palindrome‘
else:
print ‘the text is not palindrome‘
def is_palindrome2(text):
t1 = text[::-1]
if t1 == text:
print ‘the text is palindrome‘
else:
print ‘the text is not palindrome‘
def is_palindrome3(text):
r = True
for x in range(len(text)):
print x,text[x]
if text[x] != text[len(text)-x-1]:
print 1
r = False
break
if r == True:
print ‘the text is palindrome‘
else:
print ‘the text is not palindrome‘
标签:lse ext ever reverse 方法 lin abc range false
原文地址:https://www.cnblogs.com/xiaomingtx/p/9099600.html