Question: Assume M has only a countable or finite number of points and M is connected. Prove that every continuous function f:M->R is a constant function on all of M. 

Here is what I have so far:

If f: M->R is continuous and M is connected then f(M) is connected in R. Hence f(M) is an interval because it is a connected subset of R. Since M has only a finite number of points, the only interval it can be mapped to is a single point, hence f is a constant function. 

I am confused how to go from f(M) being an interval to that actually meaning it is only a single point to prove that it is a constant function.

Answer: 
The cardinality of $f(M)$ is at most the cardinality of $M$, thus countable or finite. The only nonempty intervals of $\mathbb R$ that are countable or finite are singletons.
$M$ finite implies $|f(M)|< \infty$. Since $f(M)$ is connected then it can't be a union of singletons because that is a disconnected space. Therefore, $|f(M)| = 1$ i.e $f$ is constant.