Let $I\in R$ be a nonemplty set. Show that $I$ is an interval iff any continuous function $f:I\rightarrow \{0,1\}$ is constant.
I've no idea how to handle this problem. Thanks in advance to anyone who comes up with a step - solution.
PS: I've asked a similar problem to this, but the community pointed out that the "problem" consisted of a contradiction. Indeed, due to my mistake, the question was asked wrongfully. Thanks to the people who pointed that out!
If $I$ is an interval, any $f: I \to \{0,1\}$ must be constant, since IVT tells us that if $f(a)=0<1=f(b)\implies f(c)=1/2$ for $c \in (a,b)$. This is a contradiction.
On the other hand, suppose that every continuous $f:I \to \{0,1\}$ is constant. If $I$ is disconnected, there exist nonempty disjoint open sets $A,B$ so that $A \cup B=I$. But then just set $f(A)=0$ and $f(B)=1$. This function will be continuous, a contradiction.