import random
# Pick an item randomly chosen = random.choice([1, 2, 3])
# Print out the chosen item print(chosen)
2
The choice method can be used not only with Python lists, but also with other sequences such as tuples and strings.
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.