Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 5
[Solved] be careful of returning 0 to filter() function.
Please look at these two codes: 1ļøā£ First code: def mulof3(x): if x % 3 == 0: return x m3 = list(filter(mulof3,range(10))) print(m3) #Outputs: [3,6,9] 2ļøā£ Second code: (same task with lambda function) m3 = list(filter(lambda n: n%3==0, range(10))) print(m3) #Outputs: [0,3,6,9] š Question: I can't understand why the first one doesn't output 0 in the list? Aren't these two codes the same?
0 Resposta