Skip to content
Advertisement

Picking a Random Word from a list in python? [closed]

how in python 3 would I make a list of words then have it print a random word from the list

Advertisement

Answer

Use the random.choice() function:

>>> import random
>>> a = ["Stack", "Overflow", "rocks"]
>>> print(random.choice(a))
rocks
3 People found this is helpful
Advertisement