Consider the following statement:
Let $K,Y,X$ be topological spaces such that $K \subseteq Y$ is a subspace and $X$ is contractible. Then any two continuous functions $f,g :Y \rightarrow X$ agreeing on $K$ are homotopic relative to $K$ i.e. there exists a homotopy $H: [0,1] \times Y \rightarrow X$ s.t. $H_0 = f$, $H_1 = g$ and $\forall x \in K, t \in [0,1]: H_t(x) = g(x) = f(x)$.
In generality that I have written it here, this is too strong and has a counterexample:
Let $X = Y$ be the closed infinite broom i.e. the subspace of $\mathbb{R}^2$ consisting of the union of all line segments connecting $(0,0)$ and $(1, \frac{1}{n})$ for $n \in \mathbb{N}$ and $[0,1] \times \{0\}$, and let $K := [0,1] \times \{0\}$. Let $f:= \text{id}_{X}$ and let $g: X \rightarrow X$ via $(x,y) \mapsto (x,0)$. Then assume there is a homotopy $H$ between $f$ and $g$ relative to $K$. This implies that $H$ is a strong deformation retract of $[0,1] \times \{0\} \rightarrow X$, which does not exists. (It essentially comes down to the fact that under the stated assumptions $H$ does not preserve $(1, \frac{1}{n}) \rightarrow (1,0)$).
Question: Is the statement true for $Y = [0,1]$, $K = \{0,1\}$?
If $f,g$ are loops i.e. $f(0) = f(1) = g(0) = g(1)$, then the theorem is true, since every contractible space is simply connected and so $f$ and $g$ are null homotopic.
I have tried the version for paths for the usual pathological examples of contractible spaces i.e. for the closed infinite broom (which I had used for the first counterexample), the comb space and the zig-zag-comb as given in Hatcher (see below), but I could not find a counterexample.
The zig-zag-comb:
Let $A := [0,1] \times \{0\} \cup \coprod_{q \in \mathbb{Q}} \{q\} \times [0,1]$ and glue countable many copies of $A$ as indicated in the picture below.