Search code examples
pythonrandomword-list

How to pick a random english word from a list


What would be the best way to go about getting a function that returns a random English word (preferably a noun), without keeping a list of all possible words in a file before hand?


Solution

  • Word lists need not take up all that much space.

    Here's a JSON wordlist with 2,465 words, all nouns. It clocks in at under 50K, the size of a medium-sized jpeg image.

    I'll leave choosing a random one as an exercise for the reader.