Select a random item from a list.
1 2 3 4
def setup(): words = ["apple", "bear", "cat", "dog"] word = py5.random_choice(words) py5.println(word) # Prints one of the four words
Select a random item from a list. The list items can be of any type. This function’s randomness can be influenced by random_seed().
This function makes calls to numpy to select the random items.
random_choice(objects: List[Any]) -> Any
objects: List[Any] - list of objects to choose from
Updated on September 11, 2021 16:51:34pm UTC