Proof the continuity of a function. Let $X$ be a compact and perfect subset of $\mathbb C$. Consider a sequence of sets $F_n \subset X$ such that $F_n \neq \emptyset$ is a clopen set of $X$ and $F_n \cap F_m = \emptyset, \, \forall n \neq m.$
Hence, there is $z_n \in F_n$ and, since $X$ is compact, exists a subsequence $z_{n_k} \to z_0 \in X$.
Since $F_{n_k}$ is open and $F_n \cap F_m = \emptyset, \, \forall n \neq m.$, we have that $z_0 \notin F_{n_k}, \, \forall k$.
Define the following function:
$$ f(z) = \left\{\begin{matrix}
z_{n_k}, z \in F_{n_k}
\\ 
z_0, z \in X\setminus \left ( \bigcup_{k \in \mathbb N} F_{n_k} \right )
\end{matrix}\right. $$
I'm trying to proof that $f$ is continuous in $X$.
Take $z \in F_{n_k}$ for some $k$, as $F_{n_k}$ is an open set, exists an open neighborhood $V$ of $z$ such that $f_V = z_{n_k}$, hence $f$ is constant in $z$.
Let's proof that $f$ is a continuous function in $z_0$. In fact, given $\epsilon > 0$, exists $k_0 \in \mathbb N$ s.t. $|z_{n_k} - z_0| < \epsilon, \, \forall k \geq k_0$. Since $V = B(z_0, \epsilon) \cup \left ( \bigcup_{k < k_0} X \setminus F_{n_k} \right )$ is an open set in $X$, exists $\delta > 0$ such that $B(z_0, \delta) \subset V$. Hence
$$\forall z \in B(z_0, \delta), \, |f(z) - f(z_0)| \leq sup_{k \geq k_0} |z_{n_k} - z_0| < \epsilon$$
Then, we conclude that $f$ is continuous in $z_0$.
However, I'm not getting to proof that $f$ is continuous in the other points of $\left ( \bigcup_{k \in \mathbb N} F_{n_k} \right )$.
If I take $z$ in such set, we'd have
$$ |f(w) - f(z)| \leq |f(w) - f(z_0)| + |f(z_0) - f(z)| = |f(w) - f(z_0)|, $$
since $f(z_0) = f(z) = z_0$. My problem is in define an neighborhood $V$ of $z$ that makes $|f(w) - z_0| < \epsilon$.
Help?
 A: Define $A=\bigcup_{k\in\mathbb{N}}F_{n_k}$ and let be $z\in X\setminus A$. If $z$ lies in the interior of $X\setminus A$, then you can choose an open neighbourhood of $z$ such that $f$ is constant on it. Otherwise lies $z$ on the boundary of $X\setminus A$ and we consider a sequence $(x_n)_n\subset X$ such that $x_n\to z$ for $n\to\infty$. 
It is sufficent to assume $(x_n)_n\subset A$ or $(x_n)_n\subset X\setminus A$.
If $(x_n)_n\subset X\setminus A$, we are done since $f(x_n)=z_0\to z_0=f(z)$.
So we just have to consider $(x_n)_n\subset A$. 
We define $A_m:=\bigcup_{k\leq m} F_{n_k}$.
Claim: There exists $N_m\in\mathbb{N}$ such that $x_n\in A\setminus A_m$ for all $n\geq N_m$.
Proof of claim: 
Suppose there is $m\in\mathbb{N}$ such that $(x_n)_n\subset A_m$. Since $A_{m}$ is closed in $X$ and $(x_n)_n$ convergent to $z$, we get $z\in A_{m}$. Since $z\in X\setminus A$, we have $z\in A_{m}\cap (X\setminus A)\subset A\cap(X\setminus A)=\emptyset$ a contradiction.
But neither a subsequence can be contained in $A_m$, because the subsequence is also convergent to $z$ and since $A_m$ is closed, we get again the contradiction $z\in A_m$. This proves the claim.
Now we can prove $f(x_n)\to f(z)$.
Let be $\epsilon>0$, then there exists $m\in\mathbb{N}$ such that $|z_{n_k}-z_0|<\epsilon$ for $k> m$. Using the above claim, we get $N_m\in\mathbb{N}$ such that for $n\geq N_m$ we have $x_n\in A\setminus A_m$ and therefore $f(x_n)\in\{z_{n_k}~:~k>m\}$. This yields
$$
|f(x_n)-f(z)|=|f(x_n)-z_0|\leq \sup_{k>m}|z_{n_k}-z_0|<\epsilon.
$$
Finally $f(x_n)\to f(z)$ and $f$ is continious in $z\in X\setminus A$.
