vendredi 23 septembre 2016

Python random while multiple conditions

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:

import random

a = 0
b = 0
c = 0

while a < 190 and b < 140 and c < 110: # <-- 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)

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.

Can someone help me there?




Aucun commentaire:

Enregistrer un commentaire