You can use generators to simplify nested loops and make it easier to break out of them.
If there is a 50% chance something will go wrong, then 9 times out of 10 it will.