Solution (source code)

= Solution

The finite <sigma-algebra> $\mathcal F_n=\sigma(A_1,\ldots,A_n)$ is partitioned by the nonempty <event>[events]
$$
C=\bigcap_{j=1}^n B_j,
\qquad B_j\in\{A_j,A_j^c\}.
$$
These are its <atom of a sigma-algebra>[atoms]. Define the <random variable>
$$
X_n=\sum_{C:\,\mathbb P(C)>0}
\frac{\mathbb E[X\mathbf1_C]}{\mathbb P(C)}\mathbf1_C,
$$
and give it any finite value on the union of the null atoms. It is $\mathcal F_n$-measurable and <Lebesgue integrable function>[integrable]. Every $A\in\mathcal F_n$ is a union of atoms, so
$$
\mathbb E[X_n\mathbf1_A]
=\sum_{C\subseteq A}\mathbb E[X\mathbf1_C]
=\mathbb E[X\mathbf1_A].
$$
This constructs the requested variable directly, without invoking the general existence theorem for <conditional expectation>.