Check if Palindrome
class practiceYln(): def __init__(self): # 类参数的初始化 self.text = None def checkifpalindrome(self): self.text = input('please input a word:') # input用来接收输入 if self.text == ''.join(reversed(self.text)): # 先反转字符串再拼接 print('yes, this word is a palindrome.') else: print('no, this word is not a palindrome.') #调用: tt = practiceYln() tt.checkifpalindrome() #结果是: please input a word:big no, this word is not a palindrome. please input a word:racecar yes, this word is a palindrome.
May we all proceed with wisdom and grace.
https://www.cnblogs.com/YlnChen/