There are 4 things wrong with this code. Any help will be gratefully appreciated.
Firstly it will not let me enter my own number.
Secondly it tells me that 4 is a prime number
Thirdly I get an error message..."Oops, try again. Your function fails on is_prime(2). It returns None when it should return True." . In line 11 I made a provision for 2 as a prime number
Fourthly In my last print statement I am trying to say if false print not a prime number and if true print it is a prime number.
in addition, I have tried removing some of the return statements; but, no joy unfortunately
def is_prime(x): print "you wish to find out if",x,"is a prime number!" if x ==0: print "Your number is not a prime number" return False elif x==1: print "your number is a not a prime number" return False for n in range(2,int((x-1)**0.5)): if n==2: # if the number entered is 2 then print it is a prime number print "your number is a prime number" return True elif n>2 and n%n!=0:#if the remainder after dividing by a number between 2 and the square root of the number is has not got 0 as a remainder, then the number is a prime number print "your number is a prime number" else: print "the number is not a prime number" return False number = input(" enter the number to check if it is a prime number" ) print is_prime(number), number,"is a prime number" you wish to find out if 4 is a prime number! None 4 is a prime number None .