Python: Filter List
Filter List
filter(f, list)
-
Return a new iterator, such that
f(item)
returnsTrue
.# return True if divisible by 2 def ff(n): return n % 2 == 0 aa = [0, 1, 2, 3, 4, 5] bb = filter(ff, aa) print(list(bb) == [0, 2, 4])
Python, Data Structure
- Python: List
- Python: Generate List: range
- Python: List Comprehension
- Python: List Methods
- Python: Iterate List
- Python: Map f to List
- Python: Filter List
- Python: Iterator to List
- Python: Copy Nested List, Shallow/Deep Copy
- Python: Interweave Lists to Tuples, Transpose
- Python: Sort
- Python: Convert List to Dictionary
- Python: Dictionary
- Python: Iterate Dictionary
- Python: Dictionary Methods
- Python: Tuple
- Python: Sets, Union, Intersection
- Python: Sequence Types
- Python: Read Write JSON