Oops, try again. Your function fails on is_prime(2). It returns None when it should return True.

to return true at the end

Replace this line with your code. 
def is_prime(x):
   if x < 2:
       return False
   elif x >=2:
        for n in range(2,x-1):
            if n % x == 0:
                return False
   return True


1.Indent your code properly
2. Work on code's logic again,

do reply if you solved it or not!
Hope it helps :slight_smile:


i have indented the code properly but i dnt wth the code logic am stuck pls help


I give you my logic..(there are many ways to do this problem though)

1.First I will check if x == 2, if it is then return True

2.Then I will check if number x > 2 and will test these...

         1. If this number is divisible by range of number `range(2,x)`
         2. If it is divisible by any number return False

3.last line?
I'm not telling you, Figure this out! :thinking: :slight_smile:

I hope it helps!


i get it right


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