def main():

```n = input("Please enter a number:")
is_prime(n)

def is_prime(a):
x = True
for i in (2, a):
while x:
if a%i == 0:
x = False
else:
x = True

if x:
print "prime"
else:
print "not prime"

main()```

If the entered number is not a prime number, it displays "not prime", as it is supposed to, but if the number is a prime number, it doesn't display anything. Could you please help me with it?

Oct 26, 2018 in Python 4,636 views

## 2 answers to this question.

There is an efficient way to write the same program.

The loop you wrote can be concisely rewritten in Python:

```def is_prime(a):
return all(a % i for i in xrange(2, a))```

That is, a is prime if all numbers between 2 and a (not inclusive) give non-zero remainder when divided into a.

• 58,090 points

selected Oct 14, 2019 by Omkar
```number = int(input("Enter the Number"))
if(number==1):
print(number,"is not prime Number")
elif(number==0):
print("Oh! Enter the natural number to check the prime or not")
else:
check =number//2
for i in range(2 ,check+1):
if check%i==0:
print("oh! sorry",number,"is not prime Number")
break
else:
print("congratulation!",number,"is the Prime Number")```
answered Oct 9, 2019 by Anand Kumar
Thanks a lot Anand, this solved my problem. Upvoting your answer right away... :)

## What is the logic to check if a number is prime or not in python?

n = int (input ('ENTER NUMBER TO ...READ MORE

## How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

## What is the python logic to check if a number is armstrong number or not?

a = int (input('enter number')) num = a sum ...READ MORE

## How to check whether a string contains alphabets or number in Python?

By using isAlpha () to check whether ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

## Lowercase in Python

You can simply the built-in function in ...READ MORE

+1 vote

## Is there a label/goto in Python?

No, Python does not support labels and ...READ MORE