Simple mistake?


I have used if/else statements a before and if I am not wrong this is how they are indented right??

File "python", line 4
IndentationError: expected an indented block

def is_prime(x):
    if x <= 2:
        return False


Just go with less than 2, not less than or equal to. 2 is Prime so should return True.


thanks but i'm still getting the indentation error


Well, there is code missing after the else. Wasn't sure if you had just not posted it.

Technically, since the if statement returned, no else is needed. Just start coding normally.


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