Simple mistake?


#1





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
else:
^
IndentationError: expected an indented block


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


#2

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


#3

thanks but i'm still getting the indentation error


#4

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.


#5

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