I've got all the numbers appended into list1 from x to y (inclusive). I now only need the list to contain only prime numbers from x to y inclusive
def primes(x , y):
list1 = []
for i in range(m, n + 1):
list1.append(i)
for elements in list1:
if elements % 2 == 0:
pos = list1.index(elements)
list1.pop(pos)
return list1
I've got all the numbers appended into list1 from x to y (inclusive) and also got rid of the even numbers but i cant seem to get rid of the other numbers that arent prime. I now only need the list to contain only prime numbers from x to y inclusive
For example x = 7, y = 23
list1 = [7, 11, 13, 17, 19, 23]
Thanks in advance