Loosing weight while gaining muscle

I loss quite a bit of weight. I'm 5'6 and 185lbs. I recently tested my body fat% and had 29% body fat. I've heard you can loose weight and gain muscle but is very difficult. Can anyone give me some advice as to start?