Pick a prime and non-prime number for
x, (7 and 12 are good) and then manually check if they are prime, followed by reading the code and checking that it says to do the same actions.
Try the same thing with the other indentation.
You’ll either answer your own question or find that there is something that you do not understand in your code - in which case either replace it with something that you do understand or learn about that something.
Yes, you’re supposed to know what each and every thing there does, and in almost all code that you write (You’re TELLING the computer what to do, you better know what you’re saying, if you don’t know then nobody else does either, so who then decided what should happen?). So if there’s anything that isn’t true for then you’ve found the cause of confusion and you’ve also found what you need to look up.
That code doesn’t use for-else, it’s the result of playing around with indentation and ending up with something that by accident is valid syntax and seems to do the right thing (it misses the point of for-else so anyone who knows what for-else does can spot that this was written by shuffling things around without a plan)