I find myself in this situation quite frequently, as I hang out in the php and javascript tags, which contain fewer homework questions than, say, c++ or java, but the apparent inexperience is comparable to many homework questions. These are often very simple solutions, but elude the poster due to inexperience. On one or two occasions, I've been criticized in comments for, as a high-rep user, answering a question perceived as "too easy"; but I do it when there's an opportunity to be instructive...
In php, such questions will often get downvoted into oblivion and closed as too localized or NARQ. However, I think that's the wrong course of action when a solid effort is apparent. In past experience as an instructor in a technical university course attended by mostly non-technical people, I found that the diversity and disparity between individuals' abilities to adapt to new topics to be enormous. We need to judge cautiously and with nuance what is or is not "effort" on the part of the OP.
In the example question Python referenced here, the OP did clearly bring some effort along, and it happens that this individual has quite a bit of learning left to do. This was not one of those one-sentence, no-code, no-direction types of questions, and the only real thing wrong with it is that the OP doesn't name a specific problem but instead asks generically "where I went wrong." Conventionally, that's an offense often worthy of Not a real question / Unclear what you're asking...
But hold onto your closevotes and downvotes for a second!!
Often, a poster who is only just beginning to learn to write code in a particular language is also only just beginning to be introduced to programming concepts, with which come the vocabulary to be able to ask a directed question. One thing starkly missing from my own first programming courses was any instruction whatsoever on how to begin debugging a program or read error output from the compiler (1). Basically, we all just made tiny iterative changes until our C++ assignment programs compiled, then hoped the output was correct when they did compile. This seems to be the stage this poster is at, and I find no fault there.
But you asked about answering, not voting...
I happen to believe pretty strongly that an upvote-worthy answer is one which both provides a solution, and a thorough explanation of what is going on in the supplied code. It doesn't end here though; we can extend our responsibilities as answerers outside the question as asked (and yes, I remember that this particular one had no real specifics), to offer one or two extra professional freebie pointers that will hopefully slosh around the OP's brain when the next assignment (or project) begins.
When there's a specific problem you can address in an answer, address it. Provide the code needed to solve the problem, and tell the asker how your version differs from theirs and why theirs didn't work. Link to the API where appropriate (remember, the poster may not even be aware that official online API docs exist, not for lack of effort, but lack of instruction). If there is an algorithm improvement you can suggest which is outside the scope of the original question, take the time to suggest it anyway in hope that the poster may absorb a bit of your professional experience. If I see it, I'll upvote you for sure!
You don't have to rewrite the entire thing and stick it out to the very end with the poster, but if you can supply the 2 or 3 bits of information needed to progress to the next step, you can then encourage the OP to come back and ask another question, this time with more specifics. It isn't practical to teach fundamentals, but it is practical and instructive to point the users to information they can use, as in "By the way, I recommend you read the examples on file handling in the official Python documentation(link)."
I remember that in one of the 2011 podcasts, Jeff Atwood referred to Stack Overflow as "an institution of higher learning." That really stuck with me, but I realize not everyone's mission here aligns with that sentiment.
1 Anecdotally, the two coworkers I polled this morning had similar experiences in their educations.