Returns none instead of False


#1



is_prime


Your function fails on is_prime(0). It returns None when it should return False.


returns False


def is_prime(x):
    for n in range(2, x-1):
        if x/n==0:
            return False
        else:
            return True


#2

When x is 0, how many iterations does your loop do? (Look at start and stop values before coming up with an answer, don't guess)

And, since your function always returns during an iteration, it will never do a second iteration. That loop isn't a loop.


#3

Thanks jonathan I got through the question after a couple of more tries
Thanks for the help
Tomer

בתאריך 26 בדצמ' 2016 10:14,‏ "Jonatan" codecademy@discoursemail.com כתב:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.