For a long time to access a random element in an array I used something like:
import random letters = ['a', 'b', 'c', 'd'] random_letter = letters[random.randint(0, len(letters)-1)] assert random_letter in letters
Fortunately, one day I found a smarter way to do that with random.choice(...):
random_letter_from_choice = random.choice(letters) assert random_letter_from_choice in letters