+ 1

Why it returns the same list (not working) ?.... Crt me

https://code.sololearn.com/c9U0Pc3WGD8Y/?ref=app

24th Dec 2019, 7:17 AM
Muralikrishnan
Muralikrishnan - avatar
3 Answers
+ 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'.
24th Dec 2019, 7:56 AM
Théophile
Théophile - avatar
24th Dec 2019, 8:25 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 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]
24th Dec 2019, 8:08 AM
molang
molang - avatar