how to get random word from text file in python

41

choice random word in python from a text file -

import random
print(random.choice(open('file.txt').read().split()).strip())

Comments

Submit
0 Comments