samedi 30 juin 2018

Index error when drawing elements by index from list using random.randint()'s

fruits = ['Apple','Mango','Banana','Grapes','Guava']
random.seed(500)
low =0
high = len(fruits)
random_fruits = [fruits[random.randint(low,high)] for i in range(1000)]

This is my code and following is the error what I am getting?

IndexError: list index out of range




Aucun commentaire:

Enregistrer un commentaire