Python 我有一个代码可以检测输入的句子是否是回文。但是我想让大写字母和小写字母都不起作用

Python 我有一个代码可以检测输入的句子是否是回文。但是我想让大写字母和小写字母都不起作用,python,Python,我希望此代码不关心小写或大写,请先将字符串转换为所有小写或大写字符,如下所示 string = (input("Enter your own string: ")) if string == string[::-1]: print("This is a Palindrome") else: print("This is not a Palindrome") 然后每次只需将其小写->if string.lower()==stri

我希望此代码不关心小写或大写,请先将字符串转换为所有小写或大写字符,如下所示

string = (input("Enter your own string: "))
if string == string[::-1]:
  print("This is a Palindrome")
else:
  print("This is not a Palindrome")

然后每次只需将其小写->
if string.lower()==string[::-1]。lower()
在文档中了解内置字符串函数,以供参考。如果您只搜索一点点相关关键字,如本例中的python string lower case,您将发现大量有用的结果,而无需在此处提问。这样你就不会冒着被否决或被否决的风险去回答那些你可以用最少的研究来回答自己的问题:——)被否决是因为没有测试?我的错是因为打字错误。现在决定
new_str = string.lower()
if new_str == new_str[::-1]:
   ...rest of your code here