Not seeing your question? It may still have been asked before – try () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

This list will contain other frequently asked questions that aren’t quite as popular as the ones above.

Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.

This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

hey bros I don’t like this I am pretty sure there is an additional step being made which is not necessary and shouldn’t be there.

def is_prime(x):
if x < 2:
return False
else:
for n in range(2, x-1): #I MEAN THIS LINE RIGHT HERE
if x % n == 0:
return False
return True
print is_prime(13)
print is_prime(10)

Why is there the (-1) I don’t think it should be there. Or I am just tired and it still counts it from 0… like. Range(2)… 0, 1 and then stop at x-1 for instance 10 which would mean 9, numbers 2 to 9 that is… 1, 2, 3, 4, 5, 6, 7, 8, 9… oh god damnit I see now, somebody please confirm I understand. Wait no need to I get it.

def is_prime(x):
if x < 2:
return False
else:
for n in range(2, x-1):
if x % n == 0:
return False
return True
print is_prime(13)
print is_prime(10)
print is_prime(15)

def is_prime(x):
if x == 2:
return True
if x < 2:
return False
else:
j = 0
for n in range (2, x):
if x % n == 0:
return False
return True
print is_prime(2)
print is_prime(3)
print is_prime(4)
print is_prime(5)
print is_prime(6)
print is_prime(7)
print is_prime(8)
print is_prime(9)

Hi, I was wondering if someone could help me solve my code’s problem with the 9 (the print statements are only to verify answers as you can see). It doesn’t count 9 as a prime and I was wondering why. lately, I have been troubled by multiples and 9 appears to persist somehow.