Solution (source code)

= Solution

For $x\in X$, choose $x_m\in D$ with $x_m\to x$ and define
$$
\widetilde Tx=\lim_{m\to\infty}Tx_m.
$$
The sequence on the right is Cauchy because
$$
\lVert Tx_m-Tx_l\rVert\leq\lVert T\rVert\lVert x_m-x_l\rVert,
$$
and it converges because $Y$ is complete. The same estimate shows that the limit is independent of the approximating sequence, is linear, and satisfies
$$
\lVert\widetilde Tx\rVert\leq\lVert T\rVert\lVert x\rVert.
$$
Its norm is at most $\lVert T\rVert$, while restriction to $D$ gives the reverse inequality, so
$$
\boxed{\lVert\widetilde T\rVert=\lVert T\rVert.}
$$
Any two continuous extensions agree on the dense set $D$ and hence everywhere, proving uniqueness. This is the <extension of a bounded linear operator from a dense subspace>.

Completeness of $X$ was never used, so the result remains true when $X$ is incomplete. Completeness of $Y$ is essential. For example, with $D=c_{00}\subset X=\ell^2$, let the codomain be the incomplete normed space $Y=c_{00}$ with the $\ell^2$ norm and let $T$ be the identity. An extension would have to send every limit in $\ell^2$ to itself and therefore could not take values in $c_{00}$. This is the <failure of dense-subspace extension into an incomplete codomain>.