How to create a list and only extract or find even numbers in this list?
Create a function even_only(l)that takes a list of integers as a single argument. the function will return a new list containing all (and only) elements of l that are evenly divided by 2. The original list of l will remain unchanged.
For examples, it even_only([1, 3, 6, 10, 15, 21, 28])should return [6, 10, 28]and
even_only([1, 4, 9, 16, 25])should return [4, 16].
Prompt. Start by creating an empty list and whenever you find an even number in it, add it to your list, and then return the list at the end.
captain_credible
source
share