Do I need to prove a function between two topological spaces $X, Y$ is onto to prove it induces a function on $Y$? If there is a mapping $f: X\to Y$ between two topological spaces and $X$ has a topology $T_X$ then $Y$ will have a topology $T_f$ induced by $X$ and function $f$. But recently I got confused by something my teacher said while explaining identification functions:

"If I have a mapping from $X$ to $Y$ and $X$ has a topology and if I were able to prove the mapping was onto then I can say there is a topology $T_f$ induced on $Y$ by $T_X$ and $f$ and then we can complete our prove for identification function".

So my question is, why do I need the function to be onto in order to have an induced topology on $Y$? Now I know I need onto condition to prove identification function but I am asking for the induced topology itself why do i need onto condition for that?
 A: As mentioned in the comment, it is not necessary to have a surjective function to define a topology on the codomain of $f$, but it is sufficient to have one. Indeed, if you have a function $f : (X, \tau) \rightarrow Y$ that is onto, then it induces on $Y$ a topology that is called quotient topology, where the open sets are defined in the following way:

Def: A set $B \subseteq Y$ is said to be open in $Y$ if $f^{-1}(B)$ is
an open set in $X$.

Now you can see that if $f$ is not surjective, then you may have some $y \in Y$ for which $f^{-1}(\{y\})$ is the empty set, so open in $X$ by definition. Hence, these singletons result open in the topology induced by $f$ on $Y$ and you may want to avoid this (just as an example, if you assume more structure on the topology like to be $T_1$, then these sets would be both open and closed, hence the space would result always disconnected by these isolated points).
A: Another way to see why surjectivity of the function is involved is that if you have a function $$f:X \rightarrow Y$$ you can form an equivalence relation given by the function identifying $x \sim y$ if and only if $f(x) = f(y)$. Then you see immediately that it is an equivalence relation and so you can form the quotient set $X /\sim$ and so you have the projection onto the quotient that is a surjective function $\pi : X \rightarrow X /\sim$.
As Hitman Reborn correctly pointed out, this is sufficient to define the identification topology via its definition. Nevertheless, note that to have a surjective function is not necessary; it only gives a natural definition to induce a topology on the quotient set, that is to define a topology on it that makes the projection map continuous.
