A question regarding continuous functions on metric spaces Let $X$ be a metric space and let $f$ be continuous on $X$. Then how do you show that this is true if and only if $f$ is continuous on every compact subset of $X$. I tried a contradiction approach but I that didn’t work out. Any help will be highly appreciated. 

Here $f$ is continuous iff $x_n\rightarrow x$ implies $f(x_n)\rightarrow f(x)$. 
Note that $\{x_n\}\cup \{x\}$ is a compact set. Hence continuity on compact set implies continuity.   
