Try adding print() statements into your code to understand what triggers and what doesn’t trigger. It’s the easiest way to debug issues.
Also, please don’t post screenshots of your code, but paste the code directly and format it properly. See Posting guidelines in #Help channel. It makes it way easier for us to help you.