Record of the filter step on pit

Today brush problem when it came to a question, although the feeling is not difficult, but still give yourself accidentally go around

nums = range(2,20)
for i in nums:
    nums = filter(lambda x:x ==i or x % i,nums)
print(nums)

This question requires final output code to see looked at the rules filter function is to get the process primes, as it should feel that a final settlement should be a set of prime numbers less than 20 in addition to 1, but forgot Python3 the filter function is lazy evaluation

Guess you like

Origin www.cnblogs.com/Yongzyw/p/11529932.html