Prove that if $f:X\to Y$ is a surjective function between sets, then there must exist a function $g:Y\rightarrow X$ such that $f\circ g=1_Y$.
I know that the identity function is onto, and if $f$ has right inverse, then $f$ must be onto; although, I haven't seen a proof of this. A good hint would be nice.
What would an inverse look like? For every element $y$ of $Y$, it would send $y$ to an element of $X$ in the preimage of $Y$. You can just make up such a map by choosing $g(y)$ to be any point in $f^{-1}(y).$