I've been working on a coding challenge for a while and I think it's time to step away - it works but the exception handling isn't working so I think I will see it with a fresh pair of eyes. I did solve one of them but I was solving a second one called pivotIndex (at which index of an array does the sum of the numbers to the left side of the index = sum of the numbers to the right side of the index) which I just have to handle some exceptions. IMO it's not a super clear challenge because actually one of the ones it flagged my code as wrong was because there was more than one index that satisfied the result, but my code returned the later index and the answer was asking for the index of the first instance so...I don't know it's not super fair - I'll look at it tomorrow morning.
Today I reviewed Programming Paradigms in The Self Taught Programmer - Object Oriented Programming vs. Functional Programming vs. Procedural Programming. What I recall is basically around the global scope (probably what my challenge is struggling with). In procedural programming, variables are global and the can cause unexpected errors. In functional programming, the code relies on functions that do not use or change global state - only the parameters passed into the function. Since it doesn't rely on data outside the current function, it doesn't change the data that exists outside the current function, which prevents the unexpected side effects/errors. In OOP, states are stored in objects rather than functions.
It later goes onto classes in Python - something I need some review with but again this is a bit difficult on the Kindle and I should probably write out the exercises. I recall this in the code for the Flask apps we built and in our Python lectures but I really have to review this.
Catt xx