Yes, it's fine. Either if you do it or anyone else does it.
You can also mention that you got the needed information from the comments, but since in the end by the time you post the answer the comments will be obsolete and deletion would probably be the better course of action, giving attribution is hit-or-miss here.
You can give attribution linking to the comments, but soon enough the links will be stale... (because either you or someone else can flag the comments as "no longer needed", since what they say has been incorporated in a post).
Also, attribution is required if you are quoting content. If you rephrase the knowledge you got from the comments in your own words (and even better, expand on it with additional research), attribution is not required, although it's polite to credit your sources.