So which is then? You want a one off script to just quickly crunch some numbers on a problem you still need to understand? Because that is where it is perfectly normal to get some errors and doodle around. That is the entire point of it.
Or you have a concise concept of what you are going to do, and how and why? Because that is what you do, when you program more than a “one off”.
Either you go to the store with a shopping list and you work through that list or you go browsing and see what comes up. But don’t expect to be as fast and have everything you needed, when you dont write your shopping list at home.
in this process it is just normal to get runtime errors. Your expectation is too high imo.