这是python 3,这个代码基本上检查一个单词是否在向后读时是相同的。当我通过Visual Studio执行此,什么也没有发生,我也得到了提示按任意键继续......为什么我的功能不工作?
if "__name__" == "__main__":
StartProgram()
def StartProgram():
Input = AskForDataSimple()
print(CheckIfPalindrome(Input))
def AskForDataSimple():
print("Please input the line to test.")
In = input()
return In
def CheckIfPalindrome(x):
if x[::-1] == x:
return True
else:
return False
请注意,这个简单的版本确实可以工作:
x = input()
if x[::-1] == x:
print(True)
else:
print(False)
不要编辑所有的建议到您的代码,因为它会使答案过时 – progo