Need help with checking this proof I tried to prove the following:
Let $\mathbb N$ denote the positive natural numbers. Let $X_n = \{0,2\}$ with the discrete topology and let $X = \prod_{n \in \mathbb N} X_n$. Define a function $f:X \to [0,1]$ by setting $f(x) = \sum_{n=1}^\infty {x(n) \over 3^n}$. Prove that $f$ is injective and continuous. The image $f(X)$ is called the Cantor set and consists of all real numbers $a \in [0,1]$ which can be represented as triadic decimals $a = \sum_{n=1}^\infty {a_n \over 3^n}$ such that $a_n \in \{0,2\}$ for all $n$. Given $a \in f(X)$ define $g(a)(n) = a_n$ so that $g(a) \in X$. Prove that $g$ is a homeomorphism of $f(X)$ with $X$. 
can you please read my proof and tell me if I made any mistakes? This is my proof:
To show $f$ is injective one shows that $x \neq y$ implies $f(x) \neq f(y)$. If $x \neq y$ then there is at least one $n$ such that $x(n) \neq y(n)$. Let $n$ be the smallest such $n$ and assume without loss of generality that $x(n) = 0 < 2 = y(n)$. If we denote $f(x) = X_{<n} + x(n) + X_{>n}$ and $f(y) = Y_{<n} + y(n) + Y_{>n}$ then since $Y_{<n}=X_{<n}$, $f(x)$ can only be equal to $f(y)$ if $X_{>n} = Y_{>n} + {2 \over 3^n}$, or equivalently, ${2 \over 3^n} = X_{>n} - Y_{>n}$. Since $X_{>n} - Y_{>n}$ is a sum of ${2 \over 3^k}$ for $k > n$, $f(x)=f(y)$ only if ${2 \over 3^n} = \sum_{k>n} {a_k \over 3^k}$ for $a_k \in \{0,2\}$. But as an easy computation shows, 
$$ \sum_{k = n+1}^\infty {a_k \over 3^k} \le \sum_{k = n+1}^\infty {2 \over 3^k} = {1 \over 3^n} < {2 \over 3^n}$$
For the next part: 
To show that $f$ is continuous it is enough to show that the inverse image of $(y-\delta, y+\delta) \cap [0,1]$ for $y,\delta$ arbitrary is open. Let $y \in [0,1] , \delta > 0$ be arbitrary. Note that $f^{-1} ( [0,1] \cap (y-\delta , y + \delta)) = f^{-1}([0,1])  \cap f^{-1}((y-\delta, y + \delta)) =  f^{-1}((y-\delta, y + \delta)) $. Let $x$ be any point in $f^{-1}((y-\delta, y + \delta)) $ and let $n$ be such that ${2 \over 3^n } + |y- f(x)|< \delta $. Now let $O$ be the set consisting of the singleton sets $\{x(k)\}$ for the first $n$ components and of $\{0,2\}$ otherwise. Then $O$ is open and contains $x$. Also, $f(O) \subseteq (y-\delta, y + \delta)$ since for $x' \in O$, $|y - f(x')| \le |y-f(x)| + |f(x) - f(x')| < |y-f(x)| + {2 \over 3^n} < \delta$ hence $f$ is continuous. 
The last part of the proof: 
$g$ and $f$ are inverse functions so that they are bijective. It only remains to be shown that $f$ is open. To this end, let $O$ be an open set in $X$. Then it is enough to show that $f(O)$ is open when $O$ is equal to $\{0,2\}$ in all but finitely many components. Let $f(x) = y \in f(O)$ and let $n$ be the largest index such that $O_n \neq \{0,2\}$. Then for $\delta = {1 \over 3^n}$, $f(x) \in (f(x)-\delta, f(x) + \delta)  \subset f(O)$.
 A: It’s pretty good; there are a few glitches, but they’re not in the actual logic. The first is minor: in the proof that $f$ is injective you should define $X_{<n},X_{>n},Y_{<n}$, and $Y_{>n}$. Yes, it’s true that the reader should be able to guess what they mean, but it’s also true that the reader shouldn’t have to guess.
The next one is a bit more serious, though once again a reasonably competent reader will be able to figure out what you meant. 

Now let $O$ be the set consisting of the singleton sets $\{x(k)\}$ for the first $n$ components and of $\{0,2\}$ otherwise. 

Any mathematician reading that will, on getting to $\{x(k)\}$, think that $O$ is a set that has as some of its elements certain singleton sets $\{x(k)\}$, which is emphatically not the case: these singletons are factors of $O$, not elements of $O$. What you meant is:

Now let $O=\prod_{k\in\Bbb Z^+}O_k$, where $O_k=\{x(k)\}$ if $k\le n$ and $O_k=\{0,2\}$ otherwise.

Similarly, in the last part of the proof you don’t mean 

when $O$ is equal to $\{0,2\}$ in all but finitely many components;

you mean 

when $O=\prod_{n\in\Bbb Z^+}O_n\subseteq X$ is such that $O_n=\{0,2\}$ for all but finitely many $n$.

In the last part of the proof you could stand to give just a bit more detail. Specifically, it would be kinder to the reader to give a little more explanation of why $$\big(f(x)-\delta,f(x)+\delta\big)\subseteq f[O]\;.$$
A: See my answer https://math.stackexchange.com/a/475093/87690. It describes more general construction of homeomorphism between $2^ω$ and some Cantor set. If you define $F_f$'s to be the intervals for standard Cantor set construction, you'll get your function $f$ as the homeomorphim.
