I've been stuck at this problem for a while now since I do not understand what the mistake is in my function (1) everytime I try the problem again I somehow come up with basically the same code. I looked through the forum and saw this code (2) which looks very similar to my own attempt. My question now is, in what way do (1) and (2) differ? "Return True" at the end in (1) is inside the for-loop whereas in (2) it is not but I cannot seem to understand the impact of this.
Thanks in advance
Link to problem
The code gives me an error at x = 2
def is_prime(x): if x < 2: return False else: for n in range(2,x): if x%n == 0: return False else: return True is_prime
def is_prime(x): if x<2: return False else: for n in range(2,(x-1)): if x%n == 0: return False return True is_prime