【发布时间】:2020-09-02 16:55:58
【问题描述】:
def is_palindrome(input_string):
# We'll create two strings, to compare them
if input_string[0:] == input_string[-1:]:
return True
else:
return False
预期输出如下:
print(is_palindrome("Never Odd or Even")) # Should be True
print(is_palindrome("abc")) # Should be False
print(is_palindrome("kayak")) # Should be True
我目前在所有情况下都为 False。我知道我的拼接可能在 -1 上关闭。我已经尝试交换冒号无济于事。
【问题讨论】:
-
请从intro tour 重复how to ask。首先,研究课题。其次,跟踪您自己程序的值。其中任何一个都会立即显示您的错误。
标签: python python-3.x string while-loop palindrome