Dear student
Transformer cannot work in DC because, the primary coil will create a uniform and constant magnetic field, which will fail to induce emf because transformer works on the principle of electromagnetic induction i.e. it will work only with currents that produce varying magnetic field that induces emf (as alternating current does) , but dc produces a constant magnetic field which can not induce emf
With regards