Apr-17-2017, 08:20 PM
(Apr-17-2017, 07:50 PM)volcano63 Wrote:
- The last if would better be elif
I disagree. That would give extra semantic meaning to the "divisible by 5" check that doesn't exist for the "divisible by 3" check. And extra semantic meaning serves no purpose other than to confuse whoever looks at the code in the future.
If you were to look at the code, without knowing the problem ahead of time, you'd see two options:
a) divisible by 3 and
b) divisible by 5
...except that there's an extra clause tacked on to option b that sort of reads "if it's not divisible by 5, and also if nothing else happened so far, then just use the number". Which makes you stop and wonder why option b is special compared to option a. It wouldn't be immediately obvious that it isn't obvious, it just happens to come last in the loop.