Knowledge
I write what I want. The knowledge, in my opinion, should come later.
Take, for example, my recent novel, which involves a long stay at a mental hospital. I have never been in a mental hospital (whether I should be in one or not is an entirely different argument). All I know about them is the dramatized versions in pop culture, and some scraps I found after a quick jaunt through the internet.
Is my writing accurate? Probably not. Definitely not. I am writing about something that I don't know.
But I wrote it anyway: proof that you can, technically, write what you don't know. I can write about mental hospitals.
The real question is, did I do it well?
The answer to that is, probably not. It's probably deeply flawed.
Here's the fun part: that's okay.
It doesn't matter if my view of mental hospitals is warped beyond recognition.
That's what editing is for.
Whatever glaring misconceptions exist in my first draft (or, in this case, my third draft) can be corrected in the fourth draft. Or the fifth. Or the sixth. Revision is a lengthy process. Editors exist to help you write what you don't know.
If you're writing something, and you don't know it, that's okay. Write it anyway. Then, find someone who does know it, and go from there.
You can write what you don't know. But if you want it to be good, don't be surprised if you have to learn after you write it.