Oops, try again. Your function fails on is_prime(2). It returns None when it should return True.

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

why it does not work


This won't work, because in the first run of your for loop, either if is true and false is returned or else gets executed and true gets returned. (it is important to state here that a function ends the moment a return keyword is reached)

However, you want the loop to run for all numbers, and return True after the loop is finished (if the number is prime, if the number isn't prime, the loops ends in one of its runs). To achieve this, place else outside the for loop, or remove else all together and place return True after the for loop