A function \(f\colon X\to Y\) is surjective if and only if it has a right inverse, i.e. there is a function \(g:Y\to X\) such that \(f\circ g=\id_Y\).
Proof
Let \(g\) be a right inverse of \(f\). Then for each \(y\in Y\) the function \(f\) maps \(g(y)\in X\) onto \(y\).
For the other direction we need the axiom of choice . Consider the indexed family \((f^{-1}(y))_{y\in Y}\). All sets are nonempty since \(f\) is surjective. Therefore, there is a function \(g\colon Y\to \bigcup_{y\in Y} f^{-1}(y)=X\) with \(g(y)\in f^{-1}(y)\), which is the desired right inverse.