I can't figure out how to generate random words that I don't have to type into the code in python. How would I do this? I'm kind of new to python.
Asked
Active
Viewed 145 times
1 Answers
1
You need to find a source, this could be a simple text file, a website, an excel file ...
Then you will simply load your source and use random module to generate your random words.
Pseudo-code
from random import choice
with open("my_source.txt", "r") as source:
words = source.readlines()
random_word = choice(words)
print(random_word)
Your source file should look like this
marine
python
windows
enough
sunny
Florian Bernard
- 2,399
- 1
- 7
- 21