Munkres p30 prob. 6: " , where A and B are subspaces of X. Let ; suppose that the restricted functions and are continuous. Show that if both A and B are closed in X, then f is continuous." Please let me know if the proof below is sound. I would also appreciate help on how to write it better. Thank you.

Assume x_{0}. By the definition of continuity, for every open set containing f(x_{0}) there is an open set Y_{a}containing x_{0}s.t. f|Y_{a}. If x_{0}, then Y_{a}satisfies the condition for continuity. Otherwise, x_{0}. In that case there is similarly an open set Y_{b}containing x_{0}s.t. f|Y_{b}. Choose Y_{x}= Y_{a}Y_{b}. The same reasoning applies with the sets A and B reversed. Therefore for every x_{0}there is an open set (i.e. Y_{x)}containing x_{0}s.t. f|Y_{x}. Then f is continuous on X.