I would appreciate any advice that nudges me in the right direction if the proof is wrong. But please do NOT give any solution since this is an assignment question.
Problem: Let f: X->R be a continuous function and X a connected topological space. Suppose a<b are real numbers with f(x)=a and f(y)=b, for some x,y in X. Prove that for any c in (a,b), there exists z in X with f(z)=c.
Attempted Solution: Suppose otherwise, such that there exists c in (a,b) where for all x in X, $f(x){\neq}c$. Then, $f^{-1}((c,inf)){\cup}f^{-1}((-inf,c))=X$, and $f^{-1}((c,inf))$ & $f^{-1}((-inf,c))$ are open. Also, the intersection of these sets is an empty set. Since the above sets are clearly non-empty (since f(x)=a and f(y)=b) and open, as well as disconnects X, this implies X is disconnected. But this is a contradiction since X is connected. Thus, for any c in (a,b), there exists z in X with f(z)=c.
****Please do NOT give a solution to this problem since it's an assignment problem.