回数
回?cái)?shù)是指從左到右讀和從右到左讀都是一樣的數(shù),請(qǐng)利用filter()濾掉非回?cái)?shù)(打印出1000內(nèi)所有回?cái)?shù))
def is_palindrome(n):return str(n)==str(n)[::-1] # str(n)[::-1]代表字符串從后往前讀,也代表字符串的翻轉(zhuǎn) output = filter(is_palindrome,range(1,1001))
print(list(output))
轉(zhuǎn)載于:https://www.cnblogs.com/laosun0204/p/8676525.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
- 上一篇: 一个操作系统的实现(3)
- 下一篇: Gulp-静态网页模块化