So, I dont get it why I get this bug.
9 / 3 = 3 or 9 % 3 = 0, so it should return false in this next statement, why does it return true?
if x % n == 0:
because the first value to be tested by the loop is
so then the if condition:
if 9 % 2 == 0
this is false, so it goes to the elif condition:
elif 9 % 2 != 0 or 9 / 2 != 9
both this conditions are true. so True is returned (a function stops the moment a return keyword is reached
you only want to return True after the loop has finished running.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.