So this is more of a question as to why my code works correctly. I had been messing with this code for sometime and after changing the indent on 'return True' it came out as correct. Before, I had it directly under the 'if' statement within my 'for' loop.
My question is:
Why doesn't x = 2 return as False when I have my 'return True' statement outside of this loop?
def is_prime(x): if x < 2: return False for n in range(2, x): if x % n == 0: return False return True