mercredi 14 avril 2021

I am trying to print a random index of the list using random.randint, but Im getting list index out of range

I'm newbie in programming learning Python. I'm getting started with list. In the following program I am trying to print a random index of the list using random.randint, but Im getting list index out of range. The random number is given a range which is within the length of the List.

import random

members = ["Al, Am, Da, Ma, Sa, Za"]
print("The winner is: " + members[random.randint(0,5)])



Aucun commentaire:

Enregistrer un commentaire