dimanche 5 décembre 2021

random.choice() not selecting all possibilities [closed]

random.choice() in Python does not work correctly.

I have the following function, but the following happens when called:

def Randomswitch():
    thechosenone = random.choice(range(0, 2))
    if (thechosenone == 0):
        return "WIN"
    if (thechosenone == 1):
        return "LOSE"

Randomswitch()

When Randomswitch is called it only returns WIN every time it's called.

I am breaking my head trying to figure this out.

Can anyone help me please?




Aucun commentaire:

Enregistrer un commentaire