See my code below. I keep getting an error code, and I don't understand what it means too. Where in the code can I look?
def list_true(n):
return [False for x in range(2)] + [x for x in range (2, n+1)]
assert len(list_true(20)) == 21
assert list_true(20)[0] is False
assert list_true(20)[1] is False
def mark_false(bool_list, p):
mark_false = []
for x in bool_list:
if x/p == 1:
mark_false.append(True)
elif x % p == 0:
mark_false.append(False)
else:
mark_false.append(True)
return mark_false
assert mark_false(list_true(6), 2) == [False, False, True, True, False, True, False]
def find_next(bool_list, p):
x = 0
cleared = False
for bool in bool_list:
if cleared:
if bool:
return x
if x == p and bool:
cleared = True
x += 1
return None
assert find_next([True, True, True, True], 2) == 3
assert find_next([True, True, True, False], 2) is None
def prime_from_list(bool_list):
y = [x for x, i in enumerate(bool_list) if i]
prime_from_list = []
for element in bool_list:
if element == True:
return y
return prime_from_list
assert prime_from_list([False, False, True, True, False]) == [2, 3]
def sieve(n):
bool_list = list_true(n)
p = 2
while p is not None:
bool_list = mark_false(bool_list, p)
p = find_next(bool_list, p)
return prime_from_list(bool_list)
Then I get an error message after the below code.
assert sieve(1000) == get_primes(0, 1000)
--------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-50-c49169fabbae> in <module>()
----> 1 assert sieve(1000) == get_primes(0, 1000)
AssertionError:
Why am I getting the error and is there a possible way I can amend it?