In Python 3, how would I print a random word from a list of words?
Use the random.choice() function:
random.choice()
>>> import random >>> a = ["Stack", "Overflow", "rocks"] >>> print(random.choice(a)) rocks