+ 1
Why it returns the same list (not working) ?.... Crt me
3 Respostas
+ 2
Filter works with Boolean. That means that your lambda function must compare values :
lambda x : x > 2
Maybe you're not using the right function. If you want to apply a changes for each element of the list, you should use 'map', not 'filter'.
+ 4
+ 3
There's an easier way if you want to multiply every element of your list by 2(or by any number):
l=[1,2,3,4,5,6,7,8,9,10]
print ([i * 2 for i in l])
#outputs [2,4,6,8,10,12,14,16,18,20]