Python election challenge
Your code has a problem. Candidate A can loose region 1, but win region 3.
Where with your code they can only win region 3 if they win region 2 and 1.
This is as they are independent, and so you should random in each check.
You want to move your chances outside the loop into an array.
You can simplify your ifs into one comprehension.
Candidate a wins if they have more than half the regions, you don't need to calculate the amount of regions candidate b wins.


And so you could change your code to the following:

from random import random

AMOUNT = 10000
region_chances = [87, 65, 17]
region_chances = [1 - n / 100 for n in region_chances]
regions = len(region_chances)
candidate_a_won = sum(
    sum(random() &gt;= chance for chance in region_chances) * 2 &gt; regions
    for _ in range(AMOUNT)
)
candidate_b_won = AMOUNT - candidate_a_won
print('Candidate A won elections {} times, candidate B won elections {} times'.format(candidate_a_won, candidate_b_won))




If you want to extend on the above then it'll be hard if you decide to have more than two candidates, or even amounts of states.
But as this is a challenge, I don't think you need to worry about these situations.