if $f : X \to Y$ is continuous for every topology, then $f$ is constant Let $X$ and $Y$ be sets. Prove that a function $f : X \to Y$ is continuous for every topology
on $X$ and every topology on $Y$ if and only if f is constant, that is, $f(x) = f(y)$ for all
$x, y \in X$.
I managed to prove the converse, which is quite easy. However couldn't prove the way : $\implies$
My approach in proving the way $\implies$ was letting a topology on $X$ to be discrete while letting the topology on $Y$ to be indiscrete. And using contradiction. But this didn't work out, I need to somehow show that for every topology $f$ should be constant but couldn't think of such a general argument. 
I also thought about using the fact that inverse functions preserves unions and intersection, so that for any $ \alpha_i \in Top(Y)$ Inverse of their unions should be in $Top(X)$ was my argument, which I believe could lead to the solution.
Any hints?
 A: Go the other way! Let $Y$ have discrete topology and $X$ have the trivial one. Then note that for any $y\in Y$, $\{y\}$ is an open set, so $f^{-1}(y)\subseteq X$ must also be open.
The moral of the story is that it is more difficult for a function $X\to Y$ to be continuous with a coarse topology on $X$ and a fine topology on $Y$ is. Simply because there are more open $V\subseteq Y$ that puts demands on $f$, and there are fewer open $U\subseteq X$ you are allowed to "hit" with $f^{-1}(V)$. This goes the other way too; if $X$ is discrete and $Y$ is trivial, then any function $X\to Y$ is continuous.
A: Suppose $x,x'\in X$ with $x\ne x'$ and $f(x)\ne f(x^*).$ Let $T_X=\{\phi,X, \{x\}\}.$ Let $T_Y=\{\phi,Y, \{f(x^*)\}\}.$ 
Then $\{f(x^*)\}\in T_Y$ but $f^{-1}\{f(x^*)\} \not \in T_X$ so $f$ is not continuous.
So if $f:X\to Y$ is not constant then there exist topologies on $X,Y$ such that f is not continuous. 
The smallest example of this is $X=Y=\{1,2\}$ and $T_X=T_Y=\{\phi, \{1\},X\}$ (Sierpinski space) with $f(1)=2$ and $f(2)=1.$ 
