Files
Learn-Python-Programming-Th…/ch05/gen.filter.py
T
adii1823 ef37ce0c4e ch05
2021-10-28 17:38:16 +05:30

6 lines
151 B
Python

# gen.filter.py
cubes = [x**3 for x in range(10)]
odd_cubes1 = filter(lambda cube: cube % 2, cubes)
odd_cubes2 = (cube for cube in cubes if cube % 2)