In Bishop and Bridges' "Constructive analysis" on page 17 there is a note with explanation that
If $f\colon A\to B$, $g\colon B\to A$, and $g(f(a))=a$ for all $a$ in $A$, then the function $g$ is called a left inverse of $f$ and the function $f$ is called a right inverse of $g$. (Note that $f$ has a left inverse if and only if it is one-one, in the sense that $a = a'$ for all elements $a, a'$ of $A$ with $f(a) = f(a'))$
The "left inverse implies one-one" direction is clear to me, but I can't find the way to make it work the other way around constructively. Besides the fact that it's straight up wrong when $A$ is empty and $B$ is inhabited, I can't even make it work with the assumption that $A$ is inhabited.
If $A$ is inhabited, let $c \in A$. My intuition for building such a $g$ is like follows: for any $b\in B$, if $b = f(a)$ for some $a\in A$ set $g(b) = a$, otherwise set $g(b) = c$. The problem here is that I'm assuming that there either is such an $a$ or there isn't, i.e. I'm using the law of excluded middle. Can you help me figure out how to avoid using it?