6. is_prime


#1



I need help, i really don't know what i'm doing...


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


#2

The else and the statement inside of the else is indented once too far. :slight_smile:


#3

There's something else too, you need an elif statement that says if x is equal to 2, return True.


#4

ok thanks, now it's fixed!!!! :smiley: you're really smart :yum:


#5

Glad you got it fixed, and thank ya :)!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.