Not sure what I'm doing wrong?


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/0/6?curriculum_id=4f89dab3d788890003000096#
Why is my code not accepted: Oops, try again. Your function fails on is_prime(0). It returns None when it should return False.


def is_prime(x):
    if x ==2:
        return True
    elif x < 2:
        return False
    if x > 1:
        for i in range(2,x):
            if (x % i ) == 0:
                return (False)
                break
        else:    
            return(True)
            
is_prime(0)


#2

Try refreshing the cache etc. That code does return False for 0


#3

ahhha wow I feel stupid now.
Thanks :slight_smile:


#4

In last line you are just calling a function which is just returning the value instead of that you should print the function to be able to see whether it is true or false.


#5

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