6. is_prime


#1

I am having the same problem. Can someone help me figure out the problem.

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

6.is_prime
#2

my answer covers your question as well? Your loop also ends in the first run. While it should run all values, and then return True if the number is a prime. (hint: indention)


Is_prime