6 is_prime


#1



I have such code, it returns correct answer, but I cannot get success for the lesson

What should I improve?


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

print is_prime(13)


#2

try to call your function with 0 or 1, you need if for number less than 2


#5

the lesson runs multiply test cases of your function, which include 0 and 1, and maybe even negative numbers, which aren't covered at the moment, you might want to check for numbers smaller then 2 (you can also check for numbers smaller or equal to 1, whichever you prefer)


#6

when input below 2, it should retun False

def is_prime(x):
if x<2: #just add something
return False
for n in range(2,x-1):
if x%n==0:
return False
else:
return True

print is_prime(13)