No, it should be edited - either by the answerer (in order to make the question they answered manifest) or by the asker (upon realizing that the answer does not reflect the question they intended to ask).
If a question is confusing / vague / unclear, then posting an answer to what it might be asking is a valid strategy - you might guess right - but there still needs to be that follow-up step to clarify the question at some point, lest you end up just misleading future visitors.
Edit: If you were motivated to ask by this question, then I have some specific advice:
The question is quite unclear - what's being asked for in the title is rather different from what's asked for in the body (and your answer answers neither of them, but rather provides a hint for what seems to be a tangential requirement).
The question seems rather broad. He's setting out to build a tool for visualizing molecules, but it's not clear how far he's progressed toward this goal. At very least, he's asking:
- How he can "work with" models in Python (this could be a rather broad question all on its own, depending on what he means by "work with")
- How he can accept input from the operator (presumably this means command such as "draw this model")
- How he can view the resulting rendering (either internally, or in a web browser)
While your answer provides a stepping-stone toward an answer to the very last sub-bullet above, I would have a hard time calling it a conclusive answer to the question - even if the question were edited down to just that question.
In short, you should have probably advised him to break up his question into multiple pieces, including in each enough detail that folks can provide full, useful answers. If you wanted to answer just the part about opening a web browser, you could've edited the question down to just that... However, this may not have pleased the asker, and... You'd still have wanted to flesh out your answer a bit.