The question is indeed low quality.
Keep in mind that Stack Overflow is NOT Yahoo Answers, where you can type anything you like in the question box and anyone who sees (un)fit types something in the answer box.
We want questions and answers to be useful for future visitors. To make that happen the community moderates fiercely all posts. That moderation is done with (down) votes, close votes/flags, delete votes, edits and comments.
When you arrive at any question, specially the ones that look easy, do a search, either on google, in the language/tool documentation or on Stack Overflow1.
If you find a duplicate, use a flag to indicate that or leave a comment. If the question is answered from the documentation or Google, down vote for lack of research.
When you answer such questions you achieve at least three things:
- the OP learned that on Stack Overflow you can ask what ever you want without any effort and get an answer.
- the friends of the OP get told that Stack Overflow is a great place to ask no-effort questions.
- you risk getting down votes, not because your answer is technical bad but because your answer has impact on the overall quality of the site and that is not useful (a reason for down voting posts).
tl;dr To answer your question
should I have deleted the answer because the question was poor, or should I leave my answer there
You shouldn't have answered in the first place. But after that, yes, immediate deletion is warranted. In the screenshot you see that Martijn took the honors for you, after 5 other members close voted the question.
1. unfortunately searching for symbols is broken
!=
meant in python, I answered explaining what it meant along with some (simple) example code.