Above this code I also have conditions so that if the number with which the function is called is less then 2 it returns False and if it equals 2, it return True. BUT, for me, the code that I ve inserted actually works, which I dont get. Given that the last line says return True, should the process be like: if the if condition is considered True (the remainer is 0), it returns False nad it keeps looping. At the end of the loop if it is returning False, shouldnt it return True in the end anyways, because after the loop ends, it says return True as the last line in the code?
I m not sure whether you understand me but the programme should execute a line of code after a line. So no matter what the result of the loop is, shouldnt it always be True in the end, because the last line in the code says to return True?
n = 2 while n < x: if x % n == 0: return False n += 1 return True