Random choice

  • choice


examples/numbers/random_choice.py

import random

letters = "abcdefghijklmno"
print(random.choice(letters))     # pick one of the letters

fruits = ["Apple", "Banana", "Peach", "Orange", "Durian", "Papaya"]
print(random.choice(fruits))
     # pick one of the fruits