Semi-Prime Finder

def semi_prime_count(n):
prime =
scnt = 0

for i in range(1, n + 1):
cnt = 0
for j in range(1, i + 1):
if i % j == 0:
cnt += 1
if cnt == 2:

for i in prime:
for j in prime:
if i <= j and i * j < n:
scnt += 1

return print(scnt)


The code is working out so far even with other examples, but this is not passing the test cases. I cannot figure out why this code is not being counted as an answer.

print(scnt) does not return anything
so return print(scnt) won’t return anything (or it’ll return None).

so change
return print(scnt)
return scnt
so that the function returns that value.

1 Like

Thank you for the insight!