Is there a continuous function from $[0, 1]$ onto $(0, 1)$?

If there is none, why?

And for the other side, what about open set $(0, 1)$ to closed set $[0, 1]$ with a continuous function?

Thanks


HINT: For the first one use the fact that, Continuous image of a compact set is compact.


For the other side consider $f: (0,1) \to [0,1]$ defined as $f(x)= |\cos(2\pi x)|^{2}$