def cf_record_prob_lose2(winrate, numwins, maxwins=5):
    """Probability of winning `numwins` game in an event that stops at two losses.

    >>> pct(cf_record_prob_lose2(0.6, 5))
    23.3
    >>> pct(cf_record_prob_lose2(0.45, 3))
    11.0
    """
    if numwins == maxwins:
        return pow(winrate, numwins) + numwins*pow(winrate, numwins)*(1-winrate)
    else:
        return pow(winrate, numwins)*pow(1-winrate, 2)*(numwins+1)