Proof (fundamental group when attaching cell)
Consider the open cover $$ \begin{align*} U &:= \op{int}(D^n) = D^n \setminus S^{n-1}, \\ V &:= X \cup_f (D^n \setminus \set{0}). \end{align*} $$
Note there is a strong deformation retraction $(V, x_0) \to (X, x_0)$ by sending a point on $D^{n}\setminus \set{0}$ to the closest point on $S^{n-1}$. Therefore inclusion $(X, x_0) \hookrightarrow (V, x_0)$ is a based homotopy equivalence, so induces an isomorphism $π_1(X, x_0)\xrightarrow{\sim} π_1(V, x_0)$.
$U$ is contractible, so $π_1(U, *) = 1$.
Moreover $U \cap V = \op{int}(D^n) \setminus \set{0}\isom S^{n-1} \times (0,1)$, which is path-connected and homotopy equivalent to $S^{n-1}$.
Let $y_0\in U\cap V$. By Seifert-van Kampen, inclusions induce an isomorphism $$ \begin{align*} π_1(Y, y_0) \isom \underbrace{π_1(U, y_0)}_{1} *_{π_1(U \cap V, y_0)} π_1(V, y_0) = π_1(V, y_0) / \langle \langle π_1(U\cap V, y_0)\rangle\rangle. \end{align*} $$
Pick any path $γ: x_0 \rightsquigarrow y_0$.
-
If $n \geq 3$, $S^{n-1}$ is simply connected (by a simple application of Seifert-van Kampen), so $π_1(U \cap V, y_0)$ is trivial. Therefore $π_1(Y, y_0) \isom π_1(V, y_0) \isom π_1(X, y_0)$, induced by inclusion. Performing a change of basepoint by $γ_\#$, $π_1(Y, x_0) \isom π_1(X, x_0)$ is still induced by an inclusion.
-
If $n\geq 2$, $U\cap V\simeq S^1$, so $π_1(U \cap V, y_0)\isom \Z$ generated by $γ_\#[f]$. Hence $π_1(Y, y_0) \isom π_1(V, y_0)/\langle \langle γ_\#[f]\rangle\rangle$, induced by inclusion. Changing basepoint again, we get $π_1(Y, x_0) \isom π_1(V, x_0)/\langle \langle [f]\rangle\rangle\isom π_1(X, x_0)/\langle \langle [f]\rangle\rangle$, induced by inclusion.