I hope nobody would mind if I try to do the exercise.
Clearly f$f$ is continuous on G$G$. Suppose f$f$ is continuous on x$x$ and f(x)=1/k$f\left(x\right)=1/k$. Take epsilon=1/k$\epsilon=1/k$. Let U$U$ be any neighborhood of x. U\cap G_1\cap .$x$. \cap G_{k-1}$U\cap G_1\cap .. \cap G_{k-1}$ contains an irrational number y$y$. Hence |f(x)-f(y)|=2/k > epsilon$\left|f\left(x\right)-f\left(y\right)\right|=2/k>\epsilon$. (if f(x)=-1/kIf $f\left(x\right)=-1/k$, take y$y$ to be a rational number.)