In this paper, we propose a new technique to conveniently solve the Riccati equation with both constant and variable coefficients. By combining the transformation of variables with the homotopy perturbation method, this technique possesses a fast convergence rate with high accuracy. We investigate the practicality and efficiency of the technique for several specific examples of the Riccati equation and demonstrate its accuracy by comparing the approximate solution with cases where the exact solution is known.