Solution (source code)

= Solution

For a <strict-range modification of a continuous extension>, the <closed sets> $Y$ and $Z=\{x:|f(x)|\ge1\}$ are disjoint. Choose by <Urysohn's lemma> a <continuous> $u:X\to[0,1]$ with $u|_Y=0$ and $u|_Z=1$, and define
$$
\boxed{\widetilde f=(1-u)f.}
$$
This <function> is <continuous> and agrees with $f$ on $Y$. On $Z$ it vanishes. Off $Z$ we have $|f|<1$ and $0\le1-u\le1$, so $|\widetilde f|\le|f|<1$. Hence its range lies strictly inside $(-1,1)$ on all of $X$. The construction also covers empty $Y$ or empty $Z$ by a constant separating <function> where appropriate.