TITLE: Does there exist a function such that $\lim_{x \to a} f(x) = L$ for all $a \in \mathbb R$ but $f(x)$ is never $L$?
QUESTION [10 upvotes]: Does there exist a function $f:\mathbb R \to \mathbb R$ such that $\lim_{x \to a} f(x) = L$ for
  all $a \in \mathbb R$ but $f(x) \neq L$ for all $x$?

I found such a function in $\mathbb Q \to \mathbb Q$, where $f(\frac{p}{q})= \text{first p+q digits of }\pi$ satisfies the above condition. However, I have not been able to extend it to reals. So, is such a function possible, and if it is, is there any explicit example preferably related to the above function in rationals?

REPLY [5 votes]: Suppose $f$ is such a function. Like @Tim kinsella did, set $A_n = \{x\in [0,1]: |f(x) - L| > 1/n\}.$ Then $[0,1] = \cup A_n.$ Hence some $A_{n_0}$ must be infinite. By Bolzano-Weierstrass, $A_{n_0}$ has an accumulation point $x_0.$ Thus $x_0$ is a limit of a sequence $x_m$ such that $|f(x_m) - L| > 1/n_0$ for every $m.$ Since $\lim_{x\to x_0} f(x) = L,$ we have a contradiction.