samedi 12 septembre 2020

If Condition inside a function

I have this function gameA and I don't understand why score is always equal to -1, even if side is equal to 1

import random
list = [var1,var2]
def gameA():
    game = 1
    while game<=10:
        side = random.choices(list, weights=(49, 51), k=1)
        if side == var1:    
            score = 0
        else:
            score = -1
    return score
    game+=1
gameA()

Thanks

Aucun commentaire:

Enregistrer un commentaire