When I have my second "else" statement indented to align with the "if" statement, I was receiving an error message:
"Oops, try again. Your function fails on is_prime(2). It returns None when it should return True."
However, when I align the indentation of that "else" statement with the "for" statement, the code works.
I'm confused about that because I thought "else" statements need to be indented at the same level as their respective "if" statements.
Am I thinking about this incorrectly?
# this works! def is_prime(x): if x < 2: return False else: for n in range(2,x-1): if x % n == 0: return False else: return True # this doesn't work def is_prime(x): if x < 2: return False else: for n in range(2,x-1): if x % n == 0: return False else: return True