A universal property for the subspace topology

Let $X$ be topological space and $Y$ be a subset of $X$ with $i\colon Y\to X$ the inclusion map. Show that the induced topology of $Y$ is characterized by the following property: A function $f\colon Z \to Y$ of a topological space $Z$ into $Y$ is continuous if and only if $i\circ f$ is continuous.

Solutions Collecting From Web of "A universal property for the subspace topology"

It is also helpful to see this definition of induced topology on a subset as a special case of the notion of initial topology with respect to a set of partial functions $f_\lambda: X \to X_\lambda, \lambda \in \Lambda$, where $X$ is a set, and $X_\lambda, \lambda \in \Lambda$ is a family of topological spaces. This is the topology which has a subbase the sets $f^{-1}_\lambda(U)$ for all open $U$ in $X_\lambda$ and $\lambda \in \Lambda$. It has the universal property that a function $f: Y \to X$, where $Y$ is a topological space, is continuous if and only if $f_\lambda \circ f$ is continuous for all $\lambda$. This is how for example one defines the topology on a manifold when the $f_\lambda$ are a family of charts.