Consider the set $\coprod_{i \in I} X_i$ with the disjoint union topology. Prove that this space is not connected, even if all the components are connected.
Attempt: Consider the disjoint union $(\mathbb{R} \times \{1\}) \cup (\mathbb{R} \times \{2\})$
Then, $\mathbb{R} \times \{1\}$ is open, and also closed because $$\mathbb{R} \times \{1\} = (\mathbb{R} \times \{1\}) \cup (\mathbb{R} \times \{2\}) \setminus(\mathbb{R} \times \{2\})$$
You've got the right idea, but this doesn't count as a proof. What you have proved is that the following statement is false:
However, what you have been asked to prove is that the following statement is true:
(Pedantic remark: it actually isn't true as it stands. But if you exclude the cases when $|I| = 0$ or $|I| = 1$, then it becomes true. I presume this was the intention of the author of the question.)