I don't understand why lines 6-7 aren't indented. When they are--when "else: return True" is in line with "if x % n" like I think it should be, it doesn't work.
Please provide an example of the problem. Thanks.
He was asking for this same code
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
Lines 6 and 7
This else branch is the exclusion group of the for statement. It is not in the range described.
Lessons №7 and №17 in Loops will explain your question, but I advise you to do all lessons and exercises in the order suggested by Codecademy.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.