Python random while multiple conditions
<p>Cheers, my problem is that I don't know how to do a while with multiple conditions. I really don't get it why this won't work:</p>

<pre><code>import random

a = 0
b = 0
c = 0

while a &lt; 190 and b &lt; 140 and c &lt; 110: # &lt;-- This condition here
    a = 0
    b = 0
    c = 0

    for i in range(1, 465):
        v = random.randint(1, 3)

        if v == 1:
            a = a + 1
        elif v == 2:
            b = b + 1
        else:
            c = c + 1

    result = ""
    result += "a: " + str(a) + "\n"
    result += "b: " + str(b) + "\n"
    result += "c: " + str(c) + "\n"

    print (result)
</code></pre>

<p>I want to loop this until a is above 190 AND b above 140 AND c above 110 but it stops everytime after the first run.</p>

<p>Can someone help me there?</p>

<p>Actually you are only showing "a,b,c" when the while loop iterates and you incrementing in each loop 465 times. This means if your while loop works 4 times its gonna increment a, b, c randomly 465*4 times. and your values too way small for this kinda increment. As a solution you can decrease 465 number if you make it 250 you'll see it'll work until c reaches over 110 and finishes iterating.</p>

<pre><code>for i in range(1, 250):
    v = random.randint(1, 3)
</code></pre>

<p>With 250 c reaches 114 and finishes iterating. This because that 250 / 3 ~= 83 . And when the numbers dispenses as randomly c is the most commonly reacher that it's limit. I think that you want something like this;</p>

<pre><code>import random

a = 0
b = 0
c = 0

while a &lt; 190 and b &lt; 140 and c &lt; 110: # &lt;-- This condition here
    v = random.randint(1, 3)
    if v == 1:
        a = a + 1
    elif v == 2:
        b = b + 1
    else:
        c = c + 1

    result = ""
    result += "a: " + str(a) + "\n"
    result += "b: " + str(b) + "\n"
    result += "c: " + str(c) + "\n"

    print (result)
</code></pre>

<p>It will gonna show you each increment one by one and it will gonna stop when some of the requirements meets in while loop.</p>

python random multiple-conditions