List of Primes

Write a function that will create and return a Python list of the prime numbers up to n.

That is, primeList(10) should return the list [2, 3, 5, 7] and primeList(1) should return the empty list [].

You can create an empty list like so:

primes = []

...and you can add a number to the end of an existing list using append() like this:

a = [2, 4]
a.append(6)
print(a)
# prints [2, 4, 6]



©2017 Graham Mitchell