Finding palindrome numbers
Finding palindrome numbers is also a fun topic and a simple application of the filter () function to learn python.
Solution: That is, according to the characteristics of palindrome number can be.
Method 1:1 Line Code resolves
#coding=UTF-8#寻找回文数def is_palindrome(n): s=str(n) return s[0:len(s)//2]==s[-1:len(s)//2:-1] #return str(n)==str(n)[::-1]#测试forin filter(is_palindrome,range(1000)): print(i)
Method Two: Also a line of code to solve
#coding=UTF-8#寻找回文数def is_palindrome(n): return str(n)==str(n)[::-1]#测试forin filter(is_palindrome,range(1000)): print(i)
Learning Python, the more I think of how python can be so powerful, one line of code can solve a lot of problems. The code is so short and short that it's a good point.
**真心强大**
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The implementation of Python searching for palindrome number