8. There is a fair coin, and now a continuous coin-tossing game is being played, with the following rules: During the tossing process, at any time, if an odd number of consecutive heads is followed by a tail, the game stops; otherwise, the game continues. The game is played for a maximum of 10 tosses. What is the expected number of tosses in this game? $\qquad$
8. $4 \frac{135}{256}$.

Let the mathematical expectation of the number of tosses in the game with a maximum of $n$ tosses be $E_{n}$. It is easy to see that $E_{1}=1, E_{2}=2$.
Consider the case when $n \geqslant 3$.
When the maximum number of tosses is $n$, we can discuss the following three scenarios.
(1) The first toss is a tail, with a probability of $\frac{1}{2}$, reducing it to the $n-1$ case, with a mathematical expectation of $1+E_{n-1}$;
(2) The first and second tosses are both heads, with a probability of $\frac{1}{4}$, reducing it to the $n-2$ case, with a mathematical expectation of $2+E_{n-2}$;
(3) The first toss is a head and the second is a tail, the game ends, with a probability of $\frac{1}{4}$.
In summary, we have
$$
\begin{array}{l}
E_{n}=\frac{1}{2}\left(1+E_{n-1}\right)+\frac{1}{4}\left(2+E_{n-2}\right)+\frac{1}{4} \times 2 \\
=\frac{3}{2}+\frac{1}{2} E_{n-1}+\frac{1}{4} E_{n-2}(n \geqslant 3) .
\end{array}
$$

The result can be obtained by recursion.