7. It is known that two people, A and B, are playing a game. The probability of A winning is $\frac{2}{3}$, and the probability of B winning is $\frac{1}{3}$. If one of them wins two more games than the other, the game ends. Then,
7. $\frac{18}{5}$.

Let the required mathematical expectation be $\mathrm{E} \xi$.
Notice, the probability of the game ending in two rounds is equal to
$$
\left(\frac{2}{3}\right)^{2}+\left(\frac{1}{3}\right)^{2}=\frac{5}{9} \text {. }
$$

If the game does not end in two rounds, then exactly one round must have been won, returning to the initial state, at which point the mathematical expectation is $2+\mathrm{E} \xi$. Therefore,
$$
\frac{5}{9} \times 2+\frac{4}{9}(2+\mathrm{E} \xi)=\mathrm{E} \xi \Rightarrow \mathrm{E} \xi=\frac{18}{5}
$$