Source of question : Trying to prove that if the Hilbert $H$ has an orthonormal basis, then it is separable.
Elaboration :
Let $H$ be a Hilbert space and $\{e_n : n \in \mathbb N\}$ an orthonormal basis of $H$.
Let $Y_n$ be the space such $\forall n \in \mathbb N$ :
$$Y_n = \bigg\{\sum_{i=1}^nq_ie_i : q_i \in \mathbb Q\bigg\}$$
I know that every such $Y_n$ is measurable, because $Y_n$ is (I don't know the word in English - apologies!) with $\mathbb Q_n$, because every element of it is written as a linear combination of $q_1,\dots,q_n$. Now, I know that if $Y = \cup_{n=1}^\infty Y_n$, then $Y$ is measurable as a union of measurable sets. Now, $Y$ is dense over $H$, but this is the part that I cannot show.
I know I need to show that $\forall x \in H$ and $\varepsilon >0$, $y \in Y$ it is $\| x-y\| < \varepsilon$.
Since $\{e_n\}$ is an orthonormal basis of $H$, then every $x \in H$ can be written as : $$x = \sum_{n=1}^\infty \langle x, e_n\rangle e_n$$
Thus the desired norm becomes :
$$\bigg\|\sum_{n=1}^\infty \langle x, e_n\rangle e_n - y\bigg\|$$
How should I continue now to prove $\|x-y\| < \varepsilon$ aka that $Y$ is dense over $H$ and complete my proof ?
I'm assuming that this is a real Hilbert space. Following the definition, $H$ is separable if it contains a countable dense subset.
You already found the subset $Y\subset H$; there only remains to prove that it is countable and dense in $H$.
In order to prove the latter, you already noticed that any element $x$ of your Hilbert space may be written as a combination $x=∑_{i=1}^∞⟨x,e_i⟩e_i$. The other important observation is that Parseval's Identity holds, namely $$\| x \|^2=∑_{i=1}^∞|⟨x,e_i⟩|^2.$$
Since $\| x \|$ is a finite quantity, it follows that the tail $∑_{i=N}^∞|⟨x,e_i⟩|^2 \to 0$ as $N\to \infty$. You can then choose $N$ so that the tail is small, say $∑_{i=N}^∞|⟨x,e_i⟩|^2 < \epsilon_1$ and approximate the first $N$ coordinates by $q_1, \dots, q_N \in \mathbb Q$ the same way that you would in the proof that $\mathbb Q^N$ is dense in $\mathbb R^N$.
Write that approximation as $x' = ∑_{i=1}^N q_i e_i$. We know that $x'$ is an element of $ Y_N$, so that it is contained in the proposed subset $Y$. Suppose we choose $q_1, \dots q_N$ in such a way that $$\left\|∑_{i=1}^N q_i e_i - ∑_{i=1}^N ⟨x,e_i⟩e_i\right\| < \epsilon_2.$$ Then the distance $\|x - x'\|$ between $x$ and $x'$ will be
$$ \left\|∑_{i=1}^\infty ⟨x,e_i⟩e_i - ∑_{i=1}^N q_i e_i\right\| \leq \\ \left\|∑_{i=1}^N ⟨x,e_i⟩e_i - ∑_{i=1}^N q_i e_i \right\| + \left\|∑_{i=N}^\infty ⟨x,e_i⟩\right\| < \epsilon_2 + \sqrt \epsilon_1$$
(using the triangle inequality of the norm). As $\epsilon_1$ and $\epsilon_2$ are free to choose, given any $\epsilon > 0$ you can do so in such a way that $\sqrt\epsilon_1 + \epsilon_2 < \epsilon$.
It seems that you know how to prove that $Y$ is countable, so I'll leave that to you.