Write a function called primes()
that will "filter" a list to only have prime values.
The function will receive a Python list
passed in as a parameter. It should return a new list containing only the prime numbers from the original list.
You should use your isPrime()
function that you wrote for a previous assignment. Solutions that do not use isPrime()
may not receive full credit.
Examples:
primes( [1, 2, 3, 4, 5] )
returns the list [2, 3, 5]
primes( [4, 6, 9] )
returns the empty list []
primes( range(10) )
returns the list [2, 3, 5, 7]
©2017 Graham Mitchell