Avoid Commenting Each Branch in an If/Else-If/Else Chain If Possible [DS14]
Tip DS14
As much as possible, avoid inserting a comment between each if, else if/elif, and else statements in a chain.
In other words, try to avoid the following:
The main problem with the above style is that the comments between each branch introduces extra separation that can make the different conditions seem more “disconnected” or “independent” from each other, even though they’re logically connected. That increases the likelihood of misinterpretation.
Now, there may be times where the above style cannot be completely avoided - sometimes, individual conditions/branches may have details important enough to warrant a comment before each branch. However, in most cases, see if you can have the comments either (1) inside the block for the body of each branch or (2) before the entire chain.