It works because continuity is a local property. To repair $ x_0 in (0,1) cup (1,2) $; I will handle the case with $ x_0 in (0,1) $ since a symmetric argument applies if $ x_0 in ($ 1,2). Now we know that $ f $ is continuous on $ (0.1) $. So, given $ epsilon> $ 0, we can find $ delta> $ 0 such as

$$

| f (x) – f (x_0) | < epsilon

$$

does not matter when $ x in (0,1) $ satisfied $ | x-x_0 | < delta $. Because $ (0.1) $ is open, there is $ delta ^ premium> $ 0 so small that

$$

(x_0- delta ^ prime, x_0 + delta ^ prime) subseteq (0,1)

$$

and especially, $ (x_0- delta ^ prime, x_0 + delta ^ prime) cap (1,2) = do not change anything. It gives us everything we need.

To choose $ 0 < delta ^ { prime prime} < min ( delta, delta ^ prime) $ and let $ x in (0,1) sqcup (1,2) $ to be such that $ | x-x_0 | < delta ^ { prime prime} $. By our choice of $ delta ^ premium $, we must have $ x, x_0 in (0,1) $ so that

$$

| h (x) -h (x_0) | = | f (x) -f (x_0) | < epsilon

$$

where we used that $ | x-x_0 | < delta ^ { prime prime} < delta $ in this last inequality.

Essentially, we chose $ delta ^ { premium prime}> $ 0 so small that everything $ x $ with a $ delta ^ { premium prime} $-distance $ x_0 $ live in the open decor $ (0.1) $. Therefore, $ h $ will only be determined by the continuous function $ f $ on the open interval $ (x_0- delta ^ { premium prime}, x_0 + delta ^ { premium prime}) $. As mentioned above, the same argument applies if $ x_0 in ($ 1,2) instead of.