Let $Y=\{0,1\}$ and $\mathscr{U}=\mathscr{P}(Y)$ be the discrete topology on $Y$. Prove that $(X,\mathcal{T})$ is connected if and only if there is no continuous surjective function from $X$ to $Y$.
Here is my attempt.
Let $X$ be connected. This is so if and only if $X$ cannot be expressed by the union of two non-empty sets that are separated in $X$. Let there exist a function $f: X \to Y$ that is continuous and onto. Then $f^{-1}(Y)=X$ because $f$ is onto. Well $f^{-1}(Y)=f^{-1}(\{0\}\cup\{1\})=f^{-1}(\{0\})\cup f^{-1}(\{1\})$. Then we have $f^{-1}(\{0\})$ is open because $\{0\}$ is open in $\mathscr U$ and $f$ is continuous. Mirrored logic proves the same for $f^{-1}(\{1\})$. Also, both are non-empty because $f$ is onto. Thus $X$ is equal to the union of two non-empty open sets.
I am having trouble proving why they are disjoint. Once I prove this, then by contradiction the hypothesis holds. Correct?