def is_prime(x): if x >1: if x ==2: return True else: for n in range(2,x): if x % n == 0 : return False break n += 1 else: return True else: return False
I have no idea what i wrote,can anyone explain to me ,
like,whether the " break " is necessary?
why is the 2nd else indented there, not elsewhere? i mean in my 1st attempt, it's inside "for".
why is n+1 outer than break?
why is it "if" not "while"?
FYI,I read some posts,they write more codes to filter the cases that the number is even,or cut the original x into square, i am too lazy,despite i know ,(well,maybe I don't know) it might help the programme to run faster.