I suggest that you add print statements in your code which explain to the reader what the code is doing in plain English.
Then you can read these messages and see where they go wrong, and then fix the part of the code that's responsible for that behaviour.
You might also find some mistakes simply by reading your code, because there are a couple of things that just don't add up. Print statements make these things easier to find though, so it's not like you have to stare your code down and find all your bugs that way.
For example, one thing that you can print out is the result of your conditions. This lets you tell if the conditions are correctly identifying what should be done.
So you'd print like:
Is 's length 0 ? False
Where the  is the argument and False is what your condition evaluated to.
For finding why it isn't updating, you would want to find out if any of your conditions turn true so that their bodies are executed. Either they aren't, and that's the problem, or they are, but nothing is being done in them and then you would need to look closer at that