Can someone explain why the range
in the random.randint(0, len(messages) - 1)
has a minus 1 at the end? The list has 9 values:
import random
messages = ['It is certain',
'It is decidedly so',
'Yes definitely',
'Reply hazy try again',
'Ask again later',
'Concentrate and ask again',
'My reply is no',
'Outlook not so good',
'Very doubtful']
select_number = random.randint(0, len(messages) - 1)
list_select = messages[select_number]
print(list_select)
Aucun commentaire:
Enregistrer un commentaire