FAQ: Learn Python - Practice Makes Perfect - factorial FAQ: Learn Python - Practice Makes Perfect - is_prime



This community-built FAQ covers the “s_prime” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise s_prime:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!


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

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!


2 posts were split to a new topic: Why does this Return False When x = 9?


2 posts were split to a new topic: Is prime - return indent


2 posts were split to a new topic: Prevent the return False from breaking the loop


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
        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.