Let $X$ be a compact metric space and let $f:X\to\mathbb Z$ be a continuous function. (Here $\mathbb Z$ has the Euclidean topology induced from $\mathbb R$.) Prove that $f$ can assume only finitely many values.
Idea
I'm thinking about using Weierstrass's theorem to a show a $c$ exists such that $f(c) = \sup \{f(x): x \in X\}$ and as a result $f$ can only have finite values?
Because $f$ is continuous and $X$ is compact then $f(X) \subseteq \mathbb{Z}$ is a compact set, and compact sets in $\mathbb{Z}$ are finite, why? Suppose $C$ is infinite set of integers, then the space is not compact, just pick the balls with radii less than $1$ centered at points of $C$, this would contradict the space being compact as it is an open cover with no finite subcover.