I have to prove that if, X is not the union of two disjoint non-empty closed subsets of itself, then,

Either X is empty or the only continuous functions from X to the discrete space {0,1} are the two constant functions.

Attempt at the proof:

Assume that the first one is true, and let f:X->{0,1} be continuous.

Then f inverse of zero and f inverse of one are both disjoint and closed in X.

How do i proceed further ?