6 is prime


this is my code

def is_prime(x):
    if x>2 :
        for num in range(2, x):
            if x % num != 0:
                return True
            return False    
                return False
            elif x == 1 or x == 0 :
                return False
            elif x==2:
                return True

i keep getting

  File "python", line 8
SyntaxError: invalid syntax

Oops, try again. Your code looks a bit off--it threw a "invalid syntax (python, line 8)" error. Check the Hint if you need help!


Hi @julianchee! Your code is way too off. I strongly think you really require a refresher of the previous unit. I am not really sure if the following will help, but I can give you the general structure of your is_prime method:

 - if number < 2 return False
 - loop from 2 to number as x
 - -  if x divides number return False
 - return True # loop ended here

Hope it helps!