for n in range(2,(x/2)+1):
if (x%n) == 0:
range(2,(x/2)+1) is because if suppose we take any number, let's say 11, make it half i.e 5.5, now if you think there can be no number bigger than 5.5 that could completely divide 11 and give remainder 0. Now because we want a whole number here, the value that is picked up is 5
Earlier I did
range(2,x/2) and that was wrong because in that case the
range() would pick number up till 4 for checking the divisibility of 11 which is below the half of it and hence incomplete check.
range(2,x+1) are just wastage of computing.
Thanks for helping, removing one indent of
return True worked...