Here's an untested idea, but an approach I have used before.
Put your questions in a single KM variable (or a file), one question per line
Use a KM For Each action on a lines collection in that variable
Use a variable to track the count, and build the KM variable name for each answer dynamically (or append each answer to a single variable, one line per answer).
Then you just need one IF/THEN in the For Each loop to test for your condition.
Maybe in using the questions, but getting the questions into the Dictionary could be painful and verbose. Then, even more effort just to view/edit the questions. That's why I went with using a simple text file as the source for the questions. Easy to create and maintain.
That's valid. I guess, since I utilise dictionaries a lot, I've created a bunch of macros/AppleScripts to make creating, editing, viewing and deleting them easy/easier. I probably agree that your method is better for most people who haven't done this, but I don't think there's any harm in providing an alternative way of doing things.
This is easily done with the For Each action and the Lines In collection to iterate over the variable names, and the Filter action to get the “Value of Named Variable”. Something like this:
But I also want to address a question you did not ask: How Do I Create and Maintain the LIst of Questions.
As far as I can tell, all of the above solutions pretty much ignore this question.
So I have built a solution that uses a plain text file for both the Questions and the Answers.
This makes it easy to enter, review, edit, and maintain. I don't like using a lot of KM Variables or Dictionary Keys for lists of items. KM just does not provide the tools to make entry/edit of these easy.
And, with a text file you can easily share with others for their review/input.
So here's my macro:
Example of Question in File (show in BBEdit)
(Note I am showing the "invisibles" in BBEdit so you can see TABS, SPACES, and LF)