6/15 Prime Number?


#1

def is_prime(x):
if x>=3:
for n in range(2,x):
if x%n==0:
return False
else:
return True
elif x==2:
return True
else:
return False

Even I got the congratulation, I'm not sure about the code.
Would you please help me ?


#2

The code is valid and good. It works well I looked through it and the logic works. It worked for me, too.


#3

thx. I hope I can simplify this code.


#4

can any one tell me what is the wrong with my code

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


#5

Hello, you have double else