I am doing some Python exercisses and for some reason my fucntion is returning to me opposite bool value. If statement under the function need to has "not" to work properly - can anyone explain me what am I doing wrong?
number = int(input("Enter numbers you want to check: "))
def dividers(number):
temp_tab = range(2, number)
divider = 0
for x in temp_tab:
while number % x == 0:
divider += 1
if divider > 1:
return False
else:
return True
if not dividers(number):
print("It is a prime number")
else:
print("It is not a prime number")
dividers
function is incorrect. You are always only ever returning after the first iteration (when x = 2)