We claim that if a function $f\colon A\to B$ is surjective, then it has a right inverse. We assume the Axiom of Choice, which states that given a family of nonempty subsets of a set, there is a way to choose one element in each member of the family.
Assume $f\colon A\to B$ is surjective. We will show that there exists $g\colon B\to A$ such that $$f\circ g = id_B.$$ Consider first the family defined by $$S = \{f^{-1}(q) \mid q\in B\}.$$ We will show that this is a family of nonempty, disjoint subsets of $A$.
Let $b \in B$ be arbitrary so $f^{-1}(b) \in S$. As $f\colon A \to B$, it follows that $f^{-1}(b)\subseteq A$.
As $f$ is surjective, there exists some $a\in A$ such that $f(a) = b$ so $a \in f^{-1}(b)$ hence $f^{-1}(b)$ is nonempty.
Finally, suppose there exist distinct $b_1,b_2 \in B$ such that $$ f^{-1}(b_1)\cap f^{-1}(b_2) \not = \emptyset.$$ Then let $a\in f^{-1}(b_1)\cap f^{-1}(b_2) $ which leads to $b_1 = f(a) = b_2$, which contradicts the fact that $b_1$ and $b_2$ are distinct.
Consequently, $S$ is a family of nonempty, disjoint subsets of $A$. Let $b \in B$. Then $f^{-1}(b) \in S$ so by the Axiom of Choice, there is a way to choose an element of $f^{-1}(b)$.
Call such a choice $a$. As $f^{-1}(b)\subseteq A, a\in A.$
Define $g\colon B\to A$ as $g(b) = a$ where $a$ is chosen as above. We will show that $g$ is a right inverse of $f.$ First, we will show that $g$ is a function.
Let $b\in B. $ Then such a choice exists thus every $b\in B$ has an image in $A$ under $g$. Since we choose exactly one element $a \in f^{-1}(b), $ it follows that this image is unique.
Finally, we have $$f\circ g (b) = f(g(b)) = f(a) = b $$ as $a \in f^{-1}(b)$ and we are done.
This is the first time I have written a proof using the Axiom of Choice and while I think that my argument is correct, I am not very sure whether it is precisely written. Please see if my proof is correct and suggest ways to improve the clarity of the same.