A set is recursively enumerable iff it is the range of a total recursive function A set is called recursively enumerable if it is the domain of a partially recursive function.
How can I show that this definition are equivalent to "A set is recursively enumerable iff it is the range of a total recursive function"?
I could only show one direction: if a set is the range of a total recursive function $f$, then it is the domain of a partial recursive function, by defining a function $g$, on input $y$, look for an $x$ such that $f(x)=y$.
 A: It seems that you are having difficulty somewhere with converting the informal short sketch into a fully detailed sketch. 
So let's try to see in detail how a (non-empty) set being r.e. (recursively enumerable) implies that it is the range of some total recursive function.
Let $A\subseteq \mathbb{N}$ be a non-empty r.e. set. Then, by definition, there exists a partial recursive function $f_A:\mathbb{N} \rightarrow \mathbb{N}$ such that:
$$f_A(x)=1 \quad if \, x\in A$$
$$f_A(x)=\,\uparrow \qquad if \, x\notin A$$
We want to construct a (total) recursive function $g:\mathbb{N} \rightarrow \mathbb{N}$ such that:
$$range(g)=A$$
Let's divide into two cases:
(1) A has infinite number of elements
In that case define a function such as $step:\mathbb{N}^3\rightarrow\mathbb{N}$ such that $step(i,t,x)$ returns $1$ if a program corresponding to index $i$ halts(when given the input $x$) exactly at step $t$ -- and $0$ otherwise. 
Note that since the function $f_A$ described above is partial recursive, there exists some program that computes it. The variable $x$ below is supposed to be given as input to the function $g$. Here is how we proceed with constructing the function $g(x)$: 

$i:=index\;of\;some\;program\;that\;computes\;f_A \\ n:=0 \\ m:=0 \\ while(n\neq x+1) \,\,\{ \\   a:=first(m) \\  b:=second(m) \\ \qquad if(step(i,a,b)=1) \,\,\{ \\ \qquad \,\, n:=n+1\\ \qquad \,\,y:=b  \\ \qquad \} \\  m:=m+1  \\ \} \\ return \;\; y
$

For the functions $first:\mathbb{N} \rightarrow \mathbb{N}$ and $second:\mathbb{N} \rightarrow \mathbb{N}$, see for example https://en.wikipedia.org/wiki/Pairing_function. To define them rigorously consider any computable bijective function $pair:\mathbb{N}^2 \rightarrow \mathbb{N}$. Define:
$$first(x)=\{\,a\in\mathbb{N} : \exists b\in \mathbb{N} \, (pair(a,b)=x)  \}$$
$$second(x)=\{\,b\in\mathbb{N} : \exists a\in \mathbb{N} \, (pair(a,b)=x)  \}$$
I think these definitions should be OK (but I am not fully confident). Anyway, note that the main properties of these functions are that for all $a,b \in \mathbb{N}$ we have:
$$first(pair(a,b))=a$$
$$second(pair(a,b))=b$$
(2) A has finite number of elements
Suppose the number of elements in A are $N$. Then we can write A (without repetition) as:
$$A=\{a_0,\,a_1,....,a_{N-1}\}$$
Now define:
$g(x)=a_{x} \qquad for \; 0\leq x \leq N-1 \\
g(x)=a_{N-1} \qquad for \; x \geq N$
P.S. 
The above method in case(1) doesn't repeat the elements of A (in the range of g) when it is infinite.
The method that is described in comments below the question is a little different and removes the need of having a separate case for finite number of elements.  Suppose $e\in A$. Here is a sketch for calculating $g(x)$ using that method:

$i:=index\;of\;some\;program\;that\;computes\;f_A \\ e:=some\;element\;that\;belongs\;to\;A \\ a:=first(x) \\  b:=second(x) \\ if(step(i,a,b)=1) \,\,\{ \\  y:=b  \\ \} \\ if(step(i,a,b)=0) \,\,\{ \\ \\ y:=e \\ \} \\ return \;\; y
$

A: I'll use @SSequence's notations, whose nice answer led me to this.
$step$ is the (totally recursive) function $step:\mathbb{N}^3\rightarrow\mathbb{N}$ that returns $1$ if a program corresponding to index $i$ halts(when given the input $x$) exactly at step $t$ -- and $0$ otherwise.
Let $A \neq \emptyset$ be your r.e set (finite or infinite), and $f$ a partially recursive function whose domain is $A$. Say $f$ is computed by a program whose index is $i$.
Let $a$ be the minimum of $A$.
First, we define a totally recursive function $g$ that, with input $n$, returns the pair made of a number $l$ (the number of hits) and a $l$-tuple consisting of all the $x \leqslant n$ that were accepted by $f$ in up to $n$ steps and $a$ (eventually, $a$ will appear twice).

definition of $g(n)$
$tup:=a$
$l := 1$
For $t:=0$ to $n$ do:
$\qquad$For $x:=0$ to $n$ do:
$\qquad$$\qquad$If $step(i, t, x)$ == $1$:
$\qquad$$\qquad$$\qquad$$tup:=Pair(tup, x)$
$\qquad$$\qquad$$\qquad$$l := l + 1$
Return $Pair(l, tup)$

Unpacking this result
Say we have computed $g(n)$. The length of the tuple $tup:=second(g(n))$ is $l := first(g(n))$. We can pop the last element (let's call him $x$) of tup like this :

definition of $pop(l, tup)$
"""$tup$ and $l$ are global variables"""
If $l==0$:
$\qquad$ $l:= l - 1$
$\qquad$ Return $tup$
Else:
$\qquad$ $l:= l - 1$
$\qquad$ $x := second(tup)$
$\qquad$ $tup := first(tup)$
$\qquad$ Return $x$

This can be done while $l\geqslant 0$ to recover, from the last to the first, the hits packed in $g(n)$.
Now that $g$ and $pop$ are defined, we can define the following totally recursive function $h$ whose range is $A$:

$h(0) = a$
For $m>0$, $h(m)$ is the smallest element from $g(m)$ (to be unpacked as above) that wasn't already returned by $h(0), \dots, h(m-1)$ if there is one, or $a$ otherwise.

The construction of $h$ can be achieved by primitive recursion.
