Finite mapping $f : \mathbb R^2 \to \mathbb R$

Is there an continous function $f: \mathbb R^2 \to \mathbb R$ such that $f^{-1}(a)$ is finite for every $a \in \mathbb R$?

It’s not possible for analytic or smooth but I’m curious about continous mapping.

Solutions Collecting From Web of "Finite mapping $f : \mathbb R^2 \to \mathbb R$"

Take any continuous map $f: \Bbb R^2 \to \Bbb R$. Suppose for contradiction that $f$ has finite fibers…

Choose two points $a,b \in f(\Bbb R^2)$ with $a < b$. We can do this because $f$ is non-constant, otherwise it cannot have finite fibers.

Pick a point $c \in (a,b)$. Then the set $A:=\Bbb R^2 \backslash \;f^{-1}(\{c\})$ is connected, since its complement is finite.

Thus $f(A)$ is a connected subset of $\Bbb R$. Since $a,b \in f(A)$ and since $c \in (a,b)$, it follows that $c \in f(A)$. But this contradicts the definition of $A$.