如何将引号合并到用户输入中?

How to incorporate quotation marks into a user input?

def palindrome(s):
    s=input ("Enter a phrase (**use quotation marks for words**): ")
    s.lower()
    return s[::-1]==s

palindrome(s)

这是我的代码。我如何更改它以便删除粗体部分?我使用 python 2,它不接受不带引号的字符串输入。

使用 raw_input 而不是 input。在 Python 2 input 尝试评估用户的输入,因此字母被评估为变量。

A raw_input 将完成这项工作。 This question 关于 Python 2 和 3 中的输入差异可能对您有所帮助。

此外,我认为参数s不是必需的。而 s.lower() 本身并不会改变 s.

的值
def palindrome():
    s = raw_input("Enter a phrase : ")
    s = s.lower()
    return s[::-1] == s

palindrome()