I find it’s possible to operate Python as a statically typed language if you wanted, though it takes some setup with external tooling. It wasn’t hard, but had to set up pyright, editor integration, configuration to type check strictly and along with tests, and CI.
I even find the type system to be far more powerful than how I remembered Java’s to be (though I’m not familiar with the newest Java versions).
To address this, I prefer reducing length & depth of nested code, so the
for
/while
is rarely ever not visible along with everything inside it. Others have success with editors that draw indentation lines.I occasionally use Python nested functions for this purpose