TITLE: Continuous onto function preserves number of path-connected components
QUESTION [6 upvotes]: Let $X = \{(x,y) \in \mathbb{R}^2 : y = 0\} \cup \{(x,y)\in \mathbb{R}^2: -x+y = 1\}$. We want to prove that there is no continuous onto map
$$
A:=X \cup \{(x,y) \in \mathbb{R}^2: x=0\} \overset{f}{\longrightarrow} B:=X \cup \{(x,y) \in \mathbb{R}^2 : y=1\}
$$
considering both $A$ and $B$ equipped with the Euclidean topology.
Our approach to the problem has been to remove the point $p = (0,1)$, which is the intersection of two lines, from the set of departure, and observe that this leaves $A \setminus \{p\}$ with three path-connected components. Then, regardless of where $f(p)$ lands in the codomain of the function, the number of connected components of $B \setminus \{f(p)\}$ is not preserved. Our main doubt is whether we can use this fact to prove that such a function $f$ does not exist. In other words, is the number of path-connected components preserved by a continuous and surjective function between topological spaces?

EDIT:
As mathcounterexamples.net has suggested in his answer, we cannot use the reasoning that $f$ preserves the number of path-connected components of $A$ and $B$. We are now wondering what other method of proof could we use to solve the problem. Could it be, maybe, something related to the fact that $A$ contains a closed path (triangle) and $B$ contains none? Thanks in advance for your help and answers.

REPLY [4 votes]: There is a continuous onto map from $A$ to $B$, hence your conjecture can not hold.
Using your own picture:

Take any point $o$ ("origin") in $B$. Map all the yellow, green, blue parts of $A$ to $o$. We are left with mapping the semi-straight red line to $B$.
For that, split such red line in segments of unit length: $[a_0,a_1],[a_1,a_2], \ldots$, with $a_i \in A$. Map each interval $[a_i,a_{i+1}]$ to $B$ so to form a continuous path starting and ending at $o$, so that the path runs over each point in $B$ which is at most $i$ units distant from the origin $o$ (according to the Euclidean distance).
This is continuous, since it's the gluing of paths with the same endpoint. This is also onto since any point $B$ will be eventually run over by some path because its distance from $o$ is finite.
This seems to generalize to many other cases.