def is_divisible(n, L): isprime = False if (L ==[]): # if the list is empty then the number must be prime return False else: for i in L: if (n % i) == 0: # if the number (n) does not return a remainder when devided by a number return True # in the list (i), the number must be divisible. break # once a factor is found, unnessersary to continue testing. else: isprime = True # no factors found, thus the number is a prime number, so is_divisible returns if (isprime == True): # false. return False####### initialise variables.primetotal = 0 # initialse primelist = [] ####### for n in range(2,1000): # start at 2 otherwise 1 will be taken as a factor, and all integers have 1 as a factor if (is_divisible(n,primelist) == False):# if the number is not divisible by any numbers in the prime number list (primelist): primelist.append(n) # append the number to the prime number list primetotal = primetotal + 1 # increment the total number of primes found#### print n, primelist # DEBUGGINGprint 'total primes lower than', str(n) + ':', primetotal print 'prime list:', primelist