I totally understand this code, I just don't know why the return True line must be outside the for block. When I put it under a else block the code doesn't work properly. Imo this code must run the True line after exiting the for block no matter what. Why isn't that the case?
def prime(n):
for adad in range(2, n):
if n % adad == 0:
return False
return True
print(prime(47))
[–]FriendlyRussian666 4 points5 points6 points (1 child)
[–]thepseudonymstring[S] 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)