PetGin
11 months agoOccasional Contributor
Unexpected behavior executing if, elif, else statement in Python
I wrote an if, elif, and else routine to checkpoint a header name and write the appropriate password into a required password field. When I ran the script routine it resulted in unexpected behavior. The first expression (checkpoint function) resulted in true but instead of executing the associated code block (touch & keys) and dropping out it ran the next elif, which as expected failed and then it ran the statements from the previous if statement. It completed the task but ultimately failed the test.
I’ve run similar if statements before without issue. Please see attached code snippet and log.
Any thoughts as to why this would be happening would be appreciated.