0

why am I getting none?

Checking prime-number https://code.sololearn.com/cXLteBP3zBic/?ref=app

31st May 2021, 5:36 AM
mdhb
mdhb - avatar
4 Answers
+ 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)
31st May 2021, 5:44 AM
TOLUENE
TOLUENE - avatar
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)
31st May 2021, 2:52 PM
visph
visph - avatar
0
visph thanks sir for pointing it.
31st May 2021, 2:59 PM
TOLUENE
TOLUENE - avatar