The exercise is to prove that $[0,1]\sim(0,1)$, and after reading some topics on SE I understood how it's done; I can't have a continuous function (like $f(x)=x$) because it would biject to the interval $[0,1]$ by the intermediate value theorem. So, I want to construct something a little different.
Here's what I have: $f:[0,1]\to(0,1)$, such that:
$f(x)=\begin{cases}\frac12 & x=0\\\frac1{n-2} & x=\frac1n,n\ge1\\x & x\in S\end{cases}$
and $S$ is defined as $[0,1]\backslash\{0,1,\frac12,\frac13,...\}$
I was able to prove that this function is injective, but I have some doubts about how to prove that it is surjective. By the way, I did graph it and I understand completely that it's surjective, I just don't know how I'd prove it in a formal, correct way.