Python判断给定的数是否是回文数

2022-03-11 00:00:00 判断 给定 回文

Python判断给定的数是否是回文数
回文数是指一个像16461这样“对称”的数,即:将这个数的数字按相反的顺序重新排列后,所得到的数和原来的数一样。

"""
皮蛋编程(https://www.pidancode.com)
创建日期:2022/4/2
功能描述:Python判断给定的数是否是回文数
"""


def isPalindromic(str):
    strlist = list(str)
    strlist.reverse()
    newstr = ''.join(strlist)
    if strlist == newstr:
        print("Yes,it is palindromic")
    else:
        print("No, it is not palindromic")


isPalindromic('12321')

代码在python3.9下测试通过。

相关文章