every open set can be expressed as a countable union of compact sets I'm studying Sard's theorem and I want to know why is true that every open set can be expressed as a countable union of compact sets.
Thank you!

@harmonicuser has a nice explicit construction for $\mathbb{R}^n$. But as you use the tag general topology:
In fact the statement holds in all hereditarily Lindelöf locally compact Hausdorff spaces $X$ (of which the Euclidean spaces are a prominent example): if $O\subseteq X$ is open, by local compactness plus Hausdorffness we find for each $x \in O$ an open subset $U_x$ with $\overline{U_x}$ compact and $\overline{U_x} \subseteq O$. As $O$ is Lindelöf we reduce the open cover $\{U_x: x \in O\}$of $O$  to a countable subcover $\{U_x: x \in N\}$ of $O$ (where $N \subseteq O$ is countable). Then $O = \cup_{x \in N} \overline{U_x}$ shows that $O$ is $\sigma$-compact.
If $X$ is a space then every $O$ being $\sigma$-compact implies that $X$ is hereditarily Lindelöf (so that condition is necessary) but not necessarly that $X$ is locally compact (as witnessed by $\mathbb{Q}$).
