Why the filter function does not work as I expect? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why the filter function does not work as I expect?

In the toreplace variable, I would expect [3, 7] https://code.sololearn.com/cL8j8MfU0VyL/?ref=app

21st Feb 2020, 9:59 PM
Tamás Berki
Tamás Berki - avatar
3 Answers
0
Thanks, should not it work with any kind of iterables? Only with lists?
21st Feb 2020, 10:22 PM
Tamás Berki
Tamás Berki - avatar
0
Tamás Berki I think map and filter should work for all builtin iterables, but I'll check whether there are any exceptions.
21st Feb 2020, 10:31 PM
Seb TheS
Seb TheS - avatar
0
Try removing the first 2 print statements or swapping the last 2 print statements, very confusing, I can't explain this.
21st Feb 2020, 10:38 PM
Seb TheS
Seb TheS - avatar