This is an exercise from a topological book.
Let $X$ is Hausdorff and $K$ is a compact subset of $X$. $\{U_i:i=1,2,...,k\}$ is the open sets of $X$ which covers $K$. How to prove that there exist compact subsets of $X$: $\{K_i:i=1,2,...,k\}$ such that $K=\cup^k_{i=1}K_i$ and for any $i\le k$, $K_i \subset U_i$?
What I've tried: I try to let $K_i = K\cap U_i$, then it is obvious $K=\cup^k_{i=1}K_i$, however, I'm not sure such $K_i$ is still compact in $X$. I don't know how to go on.
Could anybody help me? Thanks ahead:)