I am trying to show that given a Riemann integrable function $f$ on $[-\pi,\pi]$ and $\epsilon > 0$, there exists a continuous function $g$ such that $\int_{-\pi}^{\pi}|f(x)-g(x)|\, dx < \epsilon$.
So far, I have tried to partition $[-\pi,\pi]$ into $n$ intervals, say $[a_i,b_i]$ of length $2\pi/n$ each, and split $f$ into parts $f_i$ such that $f_i$ is continuous on each interval $[a_i,b_i]$. Then I use the Weierstrass approximation theorem to get a some polynomial $g_i$ that approximates each $f_i$ on the interval $[a_i,b_i]$.
I am not sure if this is the right approach however as I don't know if these polynomials $g_n$ will fit together to get a continuous function $g$ such that the above integral will hold. Any hints would be greatly appreciated.