Is Prime not working anymore


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/0/6?curriculum_id=4f89dab3d788890003000096


The code worked yesterday and I wanted to try different approaches today but it gives error today:

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

What am I missing here?


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


#2

here:

if n % x == 0:

why n%x? we want to see if x is divisible by the different values of n (for loop)


#3

Hah, thanks for your help (:


#6