I'm quite new and I came up with a slightly different approach to this problem. Essentially it creates a list of divisors, checks to see if that list contains 2 items(1 and x) and if so returns True, else returns False.
I was hoping to get some feedback from the more experienced here. The solution worked but I'm not sure if this was a good way to solve.
def is_prime(x): if x < 2: return False elif x == 2: return True else: num = x lis = range(1,num +1) divi =  for i in lis: if num % i == 0: divi.append(i) if len(divi) == 2: return True else: return False