This is a homework question in my analysis class:
Let $A$ and $B$ be two nonempty closed subsets of a metric space $X$ that do no intersect. Show that there is a continuous function $f:X\rightarrow [a,b]$ such that $f(x)=a$ for all $x\in A$ and $f(x)=b$ for all $x\in B$.
Can someone give me a hint?