Discuss / Python / 请问为什么直接用it = filter(lambda x: x % n > 0, it)不行

请问为什么直接用it = filter(lambda x: x % n > 0, it)不行

Topic source

GrayAshhh

#1 Created at ... [Delete] [Delete and Lock User]

只会输出2和后面所有的奇数

我试了下,这样是可以成功输出的啊,你再仔细检查下

tycoonBrain

#3 Created at ... [Delete] [Delete and Lock User]

我也不行,两脸懵逼,输出的是5和后面的素数,有些还特么是错的,什么999都来了,我也不清楚,感觉是电脑的问题.........

sorry,上次是我搞错了

https://www.zhihu.com/question/283269781/answer/432041658?utm_source=wechat_session&utm_medium=social&utm_oi=767099529588645888

这是知乎上一个大佬的回答,应该就能解释这个问题啦~


  • 1

Reply