$Seq (\mathbb{N})$ of all finite sequences of elements of $\mathbb{N}$ is countable. I have few questions to the proof of this claim that is illustrated in a textbook.
$Seq (\mathbb{N})$ of all finite sequences of elements of $\mathbb{N}$ is countable. 
Proof: Since $Seq(\mathbb{N}) = \bigcup^{\infty} _{n=0} \mathbb{N}^n,$ it suffices to produce a sequence $\left \langle {a_n | n \in \mathbb{N}}\right \rangle $ of enumerations of $\mathbb{N}^n,$ i.e. for each $n \in \mathbb{N}, a_n =\left \langle {a_n(k)| k \in \mathbb{N}}\right \rangle $ is an infinite sequence, and $\mathbb{N}^n = \{a_n(k) | k \in \mathbb{N}\}$ 
Let $g$ be a bijection from $\mathbb{N}$ to $\mathbb{N} \times \mathbb{N}.$ Define $a_1(i) = \left \langle {i}\right \rangle, \forall i \in \mathbb{N}; a_{n+1}(i) = \left \langle {b_0,...,b_{n-1},i_2}\right \rangle, $ where $g(i) = (i_1,i_2)$ and $\left \langle {b_0,...,b_{n-1}}\right \rangle = a_n(i_1).$ Hence $a_n$ is onto $\mathbb{N}^n.$
My questions: This means $a_2(i) = \left \langle {i_1, i_2}\right \rangle,$ where $g(i) =(i_1,i_2).$ Then $a_3(i) = \left \langle {i_1,i_2,i_2}\right \rangle $ $,a_4(i) =\left \langle {i_1,i_2,i_2,i_2}\right \rangle $ and $a_n(i) =\left \langle {i_1,i_2,...,i_2}\right \rangle$ etc? If so, given $f = \left \langle {f(0),...,f(n-1)}\right \rangle  \in \mathbb{N}^n,$ I don't understand how could $f $ be expressed as $a_n(i),$ for some $i \in \mathbb{N}?$
Appreciate any clear instruction. Thank you.
 A: Let $\pi_i$ be a projection of the $i$-th coordinate, and set $g_i = \pi_i \circ g$, that is
\begin{align}
g_1(i) &= i_1, \\
g_2(i) &= i_2,
\end{align} 
then your sequence looks like this:
\begin{align}
a_1(k) &= \Big\langle k \Big\rangle \\
a_2(k) &= \Big\langle g_1(k), g_2(k) \Big\rangle \\
a_3(k) &= \Big\langle (g_1\circ g_1)(k), (g_2\circ g_1)(k), g_2(k) \Big\rangle \\
a_4(k) &= \Big\langle (g_1\circ g_1\circ g_1)(k), (g_2\circ g_1\circ g_1)(k), (g_2\circ g_1)(k), g_2(k) \Big\rangle
\end{align}
and so on.
A more intuitive (by my subjective opinion) argument on the cardinality of $\mathrm{Seq}(\mathbb{N})$ would be the following function:
$$f(x_1,x_2,\ldots, x_n) = -1+\prod_{i=1}^n p_i^{x_i+1}$$
where $p_i$ is the $i$-th prime number. In other words, any number gives you a finite sequence of numbers by its prime numbers decomposition, and any sequence can be encoded as show above (be aware that this is not a bijection). The $-1$'s and $+1$'s are to deal with $0 \in \mathbb{N}$. However, appropriate proof would need to use some basic results from number theory and in result might be a bit more complex than the one you have.
I hope this helps $\ddot\smile$
A: Suppose that $n$ is minimal such that there is some sequence $\langle m_0,m_1,\ldots,m_{n-1}\rangle$ that cannot be expressed as $a_n(i)$ for any $i\in\Bbb N$; clearly $n>1$, since $\langle m_0\rangle=a_1(m_0)$. By hypothesis $\langle m_0,\ldots,m_{n-2}\rangle=a_{n-1}(k)$ for some $k\in\Bbb N$. Let $i=g^{-1}(\langle k,m_{n-1}\rangle)$; then by definition $a_n(i)=$ is the sequence obtained by concatenating $a_{n-1}(k)$ with $m_{n-1}$, and that sequence is $\langle m_0,\ldots,m_{n-2},m_{n-1}\rangle$, contradicting the choice of $\langle m_0,\ldots,m_{n-1}\rangle$. Thus, for each $n\in\Bbb N$ we do have $\Bbb N^n=\{a_n(k):k\in\Bbb N\}$.
It might be worth saying a little more about the idea behind the construction. Suppose that I have an enumeration $a_n$ of $\Bbb N^n$, and I want to enumerate $\Bbb N^{n+1}$. I can think of each $\sigma\in\Bbb N^{n+1}$ as being the concatenation of a unique sequence $\tau\in\Bbb N^n$ and a unique natural number $m$: $\sigma=\tau^\frown m$. There is a unique $k\in\Bbb N$ such that $\tau=a_n(k)$, so I can use this decomposition of $\sigma$ and the enumeration $a_n$ to associate to $\sigma$ the unique ordered pair $\langle k,m\rangle\in\Bbb N\times\Bbb N$. The function $g$ enumerates ordered pairs of natural numbers, so there is a unique $i\in\Bbb N$ such that $g(i)=\langle k,m\rangle$, and I define $a_{n+1}(i)=\sigma$. 
What we’re really doing here is defining $a_{n+1}^{-1}:\Bbb N^{n+1}\to\Bbb N$; it’s clear from the definition that we’ve defined an injection, but it should be checked that it’s a surjection. But this is clear: if $i\in\Bbb N$, let $g(i)=\langle k,m\rangle$, and observe that $a_{n+1}$ maps the sequence $a_n(k)^\frown m$ to $i$.
