题目:
python 代码:
class Solution:
def isPalindrome(self, x: int) -> bool:
x_str = str(x)
x_rev = x_str[::-1]
if x_str == x_rev:
return True
else:
return False
代码中使用的[::-1] 是用来reverse a String. The slide statement [::-1] means start at the end of the string and end at position 0, move with the step -1, negative one, which means one step backwards.
如果觉得不错,就点赞或者关注或者留言~
谢谢~