Question: I have written a code to find out if a number is prime or composite.
The code works fine when I input a prime number but when I input a composite number the output is:

```
enter number: 100
The number is not prime.
The number is prime.

```

I don't want `The number is prime` output for composite number input.
Here is my code:

```
print ('This program tells whether the number is prime or not')
print ('')

def prime(x):
  if x < 2:
    print('The number is not prime.')
  else:
    for n in range(2, x - 1):
      if x % n == 0:
        print('The number is not prime.')
        break
    print('The number is prime.')

i = input('enter number: ')
prime(int(i))

```

Please tell me what can I do to correct it.

Answer: 
The problem is the indentation, you've to move the indentation of the last line and add a `break` after that, so try using:

```
print ('This program tells whether the number is prime or not')
print ('')

def prime(x):
  if x < 2:
    print('The number is not prime.')
  else:
    for n in range(2, x - 1):
      if x % n == 0:
        print('The number is not prime.')
        break
      print('The number is prime.')
      break

i = input('enter number: ')
prime(int(i))

```
This is the recommended way to solve this problem.  

do not use hard coded print statement.  

try to return `True` or `False` instead.

```
def is_prime(x:str):
  if x < 2:
      return False
  else:
      for n in range(2, int(x/2)): # Use this for more speed
          if x % n == 0:
              return False
      return True

```

Now you can check the number is prime or not by calling this `is_prime` function

```
print('Number is prime' if is_prime(6) else 'Number is not prime')

```