Hi! I am very new to python but getting the hang of it thanks to CA. I have 2 questions:
1 - why is 2 evaluating as None?
def is_prime(x): if x < 2: print 'hi-a' return False else: print 'hi-b' for n in range(2, x-1): if x % n == 0: print 'hi-ci' return False else: print 'hi-cii' return True print is_prime(2)
This gives me ‘None’ instead of ‘False’. Any reason why this could be?
2 - Why is the range supposed to be:
I think it should be:
as this gives a list of, with x = 5, of 2, 3, 4 which is what we need. But the x-1 gives a list of 2, 3.
Really confused and any help would be really appreciated.