Proving a function is continuous at a point I'm given a function $g$ defined $g:[0,1] \to \mathbb{R}$ such that $p \in [0,1]$. Let $q \in \mathbb{R}$ where $$\lim_{x \to p}g(x) = q$$ $h$ is defined such that $h(x) = \begin{cases} 
g(x)  & x \neq p \\
q & x = p
\end{cases} $
I need to show that $h$ is continuous at $p$.
What I know: 


*

*I know that to show $h$ is continuous at $p$ I need that for any $\epsilon > 0$ there is a  $\delta > 0$ such that $d(h(x),h(p)) <\epsilon$ for all $x \in [0,1]$ where $d(x,p) < \delta$. 

*Since $\lim_{x \to p}g(x) = q$ then for any $\epsilon > 0$ there is a  $\delta > 0$ such that $d(g(x),q) < \epsilon$ for all $ x \in [0,1]$ where $d(x,p) < \delta$
Can I say that when $x=p$ clearly the results from 2 satisfy the requirements of being continuous and when $x \neq p$ then as $x \to p$ it satisfies 1?
I'm not sure how to tie everything together and if anyone could help me in the right direction I would be very grateful.
 A: It's nice to have an idea of the answer, which  you do, and you're almost there. 
First, think about the definition of continuity. What does continuity of the function $h$ at $p$ mean?

It means that $\lim_{x  \to p} h(x)$ exists and equals $h(p)$.

So, we need to assert the existence of limit, and corresponding equality. We can do this in one stroke.
To show the limit exists, let $\epsilon > 0$. We want to find $\delta > 0$ such that $d(x,p) < \delta \implies d(h(x),h(p)) < \epsilon$.
Now, we recall what is $h$. It is nothing but $g$, expect at the point $p$, where it is defined as $\lim_{x\to p} g(x)$.
What does the fact that $\lim_{x \to p} g(x) = h(p)$ imply?

It implies, most importantly, that $\lim_{x \to p} g(x)$ exists!

That is, feed the $\epsilon$ I gave you earlier into this definition. You will get a $\delta_0 > 0$ such that $d(x,p) < \delta_0 \implies d(g(x),h(p)) < \epsilon$. (Since the limit equals $h(p)$).

The above is the crucial step. At least in elementary problems, given $\epsilon > 0$, and demanding continuity, you either work out a $\delta$ using the function definition if given explicitly, or plugging it into to other limits to get various $\delta$s, and playing around with them.

Now, we know that $g(x)=h(x)$ if $x \neq p$. Hence, we have that $d(h(x),h(p)) < \epsilon$ whenever $d(x,p) < \delta_0$.
This shows, in one shot, that the limit $\lim_{p \to x} h(x) = h(p)$, and thus $h$ is continuous at $p$.
Despite my best efforts, I may have missed something out, in that case please alert me.
On that note, this process is akin to "removing a discontinuity at the point $p$ of the function $g$". For example:
$$
g(x) = \begin{cases}
1 & x \neq 0 \\
0 & x = 0
\end{cases}
$$
Then look at what $h(x)$ does at the point zero. It will "remove"  the discontinuity that $g$ had. This is to merely give intuition to your question.
