Since SO is the platform for all and not the user who actually posted the question. So I follow the pattern of writing the answer starting with the best possible way to achieve that task. And later at the end of the answer I mention the actual issue with their code.
For example, consider the question: IndexError: list index out of range… How do I print every other item in a list without it giving me this error. Here user was trying to get the alternative elements in the array list, and increasing the count by 2. But he was iterating over the count of length of list. Hence code was raising IndexError
as code tries to fetch the item more than the maximum value.
In my answer, I mentioned the actual issue at the end, and started with the best way to achieve the task.
So, my question is:
- Should the answer start with the best way to achieve task? As SO is for all. It will be much more useful for someone searching for it in the future.
- OR, Should I start with directly mentioning the actual cause of error and then illustrating the better way to achieve it? As thread was started by particular user, it will be much more relevant to the user. (knowing that starting my answer with index out of range issue won't be of much help for someone in future).
Most of the time I find myself in this situation while answering such questions.