A function continuous on each set of a countable collection of closed subsets, whose union is the domain, may not be continuous Let $\{A_\alpha\}$ be a collection of subsets of some topological space $X$ s.t. $X=\cup_{\alpha}A_\alpha.$ Let $f:X\to Y$, where $Y$ is some other topological space. Suppose that $f|A_\alpha$ is continuous for each $\alpha$. Find an example where the collection $\{A_\alpha\}$ is countable and each $A_\alpha$ is closed, but $f$ is not continuous. [Munkres Topology 2/e, 18.9(b), section 18, exercise 9, page 112]
 A: I think the following example also works [I would be glad to hear any feedback].
Let $X=[0, 1]$ be equipped with subspace topology inherited from the standard topology of $\mathbb{R}$. Let $A_{0}=\{0\}$, and $A_{n}=[\frac{1}{n}, 1]$ for each positive integer $n$. Note that $A_{i}$ is closed for each $i\geq 0$ and that $X=\bigcup_{n\geq 0} A_{n}$. Define $f: X\to\mathbb{R}$ by 
$$
f(x)=\begin{cases}
0 &\textrm{if } x=0 \\
1 &\textrm{if } x\neq 0
\end{cases}
$$
Then $f$ restricted to $A_{i}$ is continuous for each $i$ (Namely, for $i=0$, it is the constant function $0$, and for $i\neq 0$ it is the constant function $1$). On the other hand, $f$ is not continuous because inverse image of $(-\frac{1}{2},\frac{1}{2})$ under $f$ is $\{0\}$ which is not open in $X$.
A: Let $f:\mathbb{Z}\to\mathbb{R}$ be the identity function, where $\mathbb{Z}$ is equipped with the cofinite topology. Then if the collection of closed sets is the singletons $\{\{n\}\}_{n\in\mathbb{Z}}$, $f|\{n\}$ is constant, hence continuous; but $f$ is not continuous on $\mathbb{Z}$ because the open set $(-\frac{1}{2},\frac{1}{2})$ in $\mathbb{R}$ has preimage $\{0\}$ which is not open in the cofinite topology.
Note: When $\{A_\alpha\}$ is a finite collection of closed sets, $f$ is continuous by the pasting lemma.
