-2

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.

martineau
  • 99,260
  • 22
  • 139
  • 249
Kitten
  • 1
  • 1
    Possible duplicate of [Random word generator- Python](https://stackoverflow.com/questions/18834636/random-word-generator-python) – Nick Reed Oct 21 '19 at 16:26

1 Answers1

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