Any condition for filter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Any condition for filter?

Shall we use any condition to filter out values from the list?

21st Oct 2016, 7:43 AM
Kiran K L
Kiran K L - avatar
2 Answers
+ 1
Yes, but know that whichever condition you use must at least be true for at least one of the items in an iterable. Check out this code https://code.sololearn.com/ciOl7W4tds18 and look at the last segment, you can use it to check if any of the items matches your filter.
10th Dec 2016, 7:34 PM
Boluwatife Olabiran
0
Yes Sure, using filter without condition is meaningless, because it will iterate on all list items like map does. check this code: https://code.sololearn.com/cNmhCfMXggAP/#py
31st Oct 2016, 6:26 PM
Khaled Sayed
Khaled Sayed - avatar