Let $(X,d)$ be a metric space an $p\in X$ be any point. I want to show that a function $f:X\to\mathbb R$ defined by $f(x)=d(x,p)$ is continuous.
My attempt:
Let $G\subseteq\mathbb R$ be open and nonempty. It suffices to show that $U=f^{-1}(G)$ is open. Let $u_0\in U$. We have $u_0\in f^{-1}(G)$, so $f(u_0)\in G$. $f(u_0)$ is an element of the open set $G$. It follows that there is some $r>0$ so that $(f(u_0)-r,f(u_0)+r)\subseteq G$. Then, $u_0\in f^{-1}((f(u_0)-r,f(u_0)+r))\subseteq f^{-1}(G)=U$...
I am not sure what to do after this point. I need to find an open interval that contains $u_0$ and fits in $U$. Any ideas?