Liu's Algebraic Geometry Ex 2.12 The exercise to be shown is

Let $f:X \rightarrow Y$ be a morphism of ringed topological spaces. Let $V$ be an open subset of $Y$ containing $f(X)$. Show that there exists a unique morphism $g:X \rightarrow V$ whose composition with the open immersion $i:V \hookrightarrow Y$ is f.

My attempt so far:
Define the map $g$ on topological spaces to be $g(x) = f(x)$. Define the map $g^\#:\mathcal{O}_V \rightarrow g_*\mathcal{O}_X$ as given by for every $W \subset V$ open, $g^\#_W:\mathcal{O}_V(W) \rightarrow g_*\mathcal{O}_X(W) = \mathcal{O}_X(g^{-1}(W))$ by $s \mapsto f^\#(s)|_{g^{-1}(W)}$.
I'm not sure if that latter map is right.
Clearly we have that the composition of the maps of topological spaces is f. But I'm not sure about the map of sheaves. Clearly, we have that $(i \circ g)^\#_V:\mathcal{O}_Y(V) \rightarrow \mathcal{O}_X ((i \circ g)^{-1}(V)) = \mathcal{O}_X(f^{-1}(V))$ goes to the right place. But I'm confused about the induced map of sheaves. Will it is given by $s \mapsto g^\#(i^\#(s)) = g^\#(s) = f^\#_{f^{-1}(V)}(s)$? I'm fairly certain I'm misunderstanding something about these maps.
Any help understanding the sheaf map and the latter part of this exercise would be appreciated
 A: I'm not sure why you write $s \mapsto f^\#(s)|_{g^{-1}(W)}$.  The set $g^{-1}(W)$ is equal to the set $f^{-1}(W)$, so $f^\#(s)$ is already an element of $\mathcal{O}_X(g^{-1}(W))=\mathcal{O}_X(f^{-1}(W))$.  In other words, you can just define $g^\#_W$ to be literally the same thing as $f^\#_W$, since $\mathcal{O}_V(W)=\mathcal{O}_Y(W)$ and $\mathcal{O}_X(g^{-1}(W))=\mathcal{O}_X(f^{-1}(W))$.
Here's how you then verify that $(i\circ g)^\#=f^\#$.  For any open $W\subseteq Y$, $i^\#:\mathcal{O}_Y(W)\to\mathcal{O}_V(i^{-1}(W))=\mathcal{O}_V(V\cap W)=\mathcal{O}_Y(V\cap W)$ is just the restriction map.  So $(i\circ g)^\#_W:\mathcal{O}_Y(W)\to\mathcal{O}_X(g^{-1}(V\cap W))=\mathcal{O}_X(f^{-1}(V\cap W))$ is just the map that takes a section, restricts it to $V\cap W$, and then applies $g^\#_{V\cap W}=f^\#_{V\cap W}$.  Since $f^\#$ is compatible with restriction, this is the same as first applying $f^\#_W$ to get an element of $\mathcal{O}_X(f^{-1}(W))$ and then restricting it to $\mathcal{O}_X(f^{-1}(V\cap W))$.  But $f^{-1}(W)=f^{-1}(V\cap W)$, so this last restriction does nothing, so this says $(i\circ g)^\#_W=f^\#_W$.
