Let X and Y be topological spaces and f : X → Y be a continuous function. Prove that for every a ∈ Y the set $f^{−1}$({a}) is a closed set. Assume that X is connected. Characterize all continuous functions f : X → Y for which $f^{−1}$ ( { a } ) is open as well.
I used the answer of Can continuity be proven in terms of closed sets? to proof the first part (for sets instead of a single element of Y). But I cannot characterize all continuous functions.