Lets return a random word of N length with Python
Yet again Reddit got the better of me again and I ended up helping a random stranger on their programming travels. Enjoy!
# wget https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt
import random
def have_a_word(l):
with open('words_alpha.txt') as f:
all_words = f.read().splitlines()
return random.choice([i for i in all_words if len(i) == l])
word = have_a_word(3)
print(word)
Thanks for reading. x