0
why am I getting none?
Checking prime-number https://code.sololearn.com/cXLteBP3zBic/?ref=app
3 Réponses
+ 1
def checkIfPrime (numberToCheck):
for x in range(2, numberToCheck):
if (numberToCheck%x == 0):
return False
return True
answer = checkIfPrime(7)
print(answer)
*removed 2 tab from return True(edited)
0
# removed one more tab from "return True" line (Md Sayed correction fail for 15, as example: the loop exit at first iteration) ^^
def checkIfPrime (numberToCheck):
for x in range(2, numberToCheck):
if (numberToCheck%x == 0):
return False
return True
answer = checkIfPrime(15)
print(answer)
0
visph thanks sir for pointing it.