is_prime


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

Oops, try again. Your function fails on is_prime(0). It returns True when it should return False.

What is wrong? This is seriously getting annoying

```python def is_prime(x): for n in range(2, x - 1): if x % n == 0: return False else: return True
<do not remove the three backticks above>

#2

you need to check some exceptions (with if … ) - what happens if you pass 0 or 1 into your function? They both should return False, do they?


#3

also, the range function goes from the first argument to the second argument but does not include the second argument - e.g. range(1,5) would return 1, 2, 3, 4

def is_prime(x):
    if x < 2:
    return False
    for n in range(2, x):
        if x % n == 0:
            return False
    else:
        return True