I've checked the other q&as for this but still can't work out my code keeps getting errors at is_prime(9)

# 6 is_prime code

**cookie92**#1

**dawidrz87**#3

Try this: replace last `elif`

with `else:`

and also change the indentation to be on the same level as `for`

.

Remember to change `return`

indentation as well.

**cyberzyme**#5

Sorry wrong person on that last answer.

This will work much better

`def is_prime (x):

```
if x < 2:
return False
if x == 2:
return True
for n in range (2, x):
if x % n == 0:
return False
else:
return True`
```

**pkarthicbz**#8

Can any one please explain how this code

```
def is_prime(x):
if(x <2):
return False
if x == 2:
return True
for n in range(2, x):
if(x % n == 0):
return False
else:
return True
is_prime(9)
```

I am having doubt about how for loop works here