Nevertheless, I answered in good faith, using code examples written by me. Penalizing learners for their newbie mistakes seems harsh for a site that purports to support all comers in their efforts to learn and help.
Unfortunately for your case, that's not how Stack Overflow works. People (e.g. "learners") are involved only as a function to create useful content; the point and goal of the site, at least originally, is to create a useful repository for programming Q&A (without excessive duplication). While that's changing over time as the company behind the site focuses more on profit than on quality, that mission statement has not been directly countered by staff to my knowledge.
In some cases, duplicates are useful because they act as signposts to the best, most canonical question and set of answers on a specific subject for people who might Google things a bit differently than we'd expect. In other cases, though, duplicates are not useful, either because we simply have so many duplicates already or because the specific permutation of the duplicate is such that it's contrived or specific to the point of not being particularly applicable to anyone beside the asker.
It's great that you answered a question and that it was accepted. Keep that drive to help others! But also try to keep in mind that, if you get the feeling a question is very basic, and has probably been answered before, then it's better for you to spend some time looking for a duplicate instead of writing an answer. You can do both, and just wait to submit the answer until after you've been unsuccessful in finding a duplicate... but it's better for you in this case and for the OP to focus on finding that duplicate first.
I few minutes ago I tried to answer another question and found that my answering privileges have also been rescinded.
What you probably mean is that you've been temporarily answer-banned. It's important to note this doesn't happen from a single deleted answer (certainly not one that was accepted and possibly upvoted!); you need to have multiple negatively-scored and/or deleted answers to land an answer ban. See
The ban will be lifted automatically by the system when it determines that your positive contributions outweigh those answers which were poorly received.
If you need assistance with this, a moderator can give you links to any deleted answers of yours that you may have lost or forgotten about. As always, you (and anyone else) can see any undeleted answers of your own by visiting your own profile page.