I can imagine basically three types of homework-related questions that might be asked:
- I have this homework, how do I do it?
- I have written this code as part of my homework assignment. Are there any obvious problems with my design or can it be prettified/optimized in any way?
- I have written this code as part of my homework assignment. Is it correct?
The first one is off-topic here simply because "How do I do this?" questions aren't in scope for this site - whether it's homework or not.
The second isn't problematic because in that case the person has already done their homework and we're just helping them to do it better. In my experience programming assignments are graded on correctness, not code quality. So we're not helping them to get a better grade for the assignment - we're just helping them to improve their programming style.
The only one that seems problematic is the third because if we fix the person's code for them, we help them get a better grade than they'd have gotten otherwise. On the other hand if they already have almost-working code, they might have gotten an okay grade anyway.