Ask coding questions

← Back to all posts
How to use random word module?
[deleted]

I want to know how to run the random word module in python 3. When I tested it out on my repl, nothing happens! So I want to know an example repl using the random word module.

Answered by Roar123 [earned 5 cycles]
View Answer
Voters
AddielLeon
Roar123
Comments
hotnewtop
Roar123

Well there are two approaches, you can use a library with words or write words to a source and pick a word from there. The easiest and fastest solution would be to copy paste words into a text file, such that each line has one word. The you would read a random line from that text and select your answer.

Note you could just read the entire contents of the text file and pick a word from there, but linecache.getline() does this optimally.
Here's the link to the repl with the code I wrote above:
https://repl.it/@Roar123/AdeptLightsalmonDemoware
Also the words are from MIT

SixBeeps

What is the exact module you are trying to use?

[deleted]

@SixBeeps The Random_Word module