[Tutor] Advice for my function, isPrime(n), please
Kent Johnson
kent37 at tds.net
Fri Jul 18 19:03:59 CEST 2008
On Fri, Jul 18, 2008 at 11:32 AM, Dick Moores <rdm at rcblue.com> wrote:
> if x == 0:
> return False
> else:
> return True
Could be just
return x!=0
or
return not x
> My question is about whether to test for integerhood. Without that test,
> isPrime(3.7) returns true, and isPrime('44') returns False. I've gone with
> testing for integerhood, and with returning None when n fails the test.
Better to raise TypeError.
Kent
More information about the Tutor
mailing list