Prove: f is surjective iff f has a right inverse.

f is surjective if for all b in B there is some a in A such that f(a) = b.

f has a right inverse if there is a function h: B ---> A such that f(h(b)) = b for every b in B.

i. Suppose f has a right inverse h: B --> A such that f(h(b)) = b for every b in B. Then for each b in B, let a in A such that f(a) = b. Let h(b) = a, then f(h(b)) = f(a) = b. Thus f is surjective.

ii. Suppose f is surjective. That is, for every b in B, there is some a in A such that f(a) = b.How to show that f has a right inverse? Please help. Thank you.