Share your repls and programming experiences

← Back to all posts
Random English Words!
Th3Coder (68)

Introduction

The English language has A LOT of words! (I mean, pretty much every single language does right? Tell me if I'm wrong!)

From 1-letter words such as a and I to Hippopotomonstrosesquippedaliophobia (ironically, that means the fear of long words), there are a lot of words!

However, the exact amount of words in the English language is uncertain. In this page alone, you will see tons of different sources and researches that state different amounts of words in the English language!

In the corncob list of words, you will see more than 58,000 words. That's not even all of them!

Randomizing Words

But what if we put all the words to a list, then pick a random one from the list?

That's exactly what I did.

Now you can choose how many random English words you want to get! You'll get them randomized from 58,111 words!

Enjoy!

Note: Wait a bit because it lags!

Also, thanks for reading all this! Share your thoughts in the comments below and tell me if there are any mistakes in the post, thanks! :)

Comments
hotnewtop
ErrorNoInternet (13)

You could just put all the words in a file and load them into an array. No need to put all the words in your code.

Th3Coder (68)

@ErrorNoInternet wait, I didn't know you can access arrays from another file using Python! Can you tell me how? Also thanks for the suggestion :)

Edit: I copied the entire list in laptop, then pasted in to a Python string and split it to a list using:

split("\n")

So, all I needed to do was just copy and paste the words, use split, and Python will make a list with it! I didn't make it manually, that would take eons 🤣🤣🤣

ErrorNoInternet (13)

@Th3Coder You need to open the file and then split the file using new lines:

file = open("wordlist.txt", "r")
fileData = file.read().splitlines()
file.close()

Now you have an array of all the lines in the file

ErrorNoInternet (13)

@Th3Coder If you wanted to actually load an array from a file, you need the json module

import json
file = open("file.txt", "r")
fileData = file.read()
file.close()
array = json.loads(fileData)

I'm not 100% sure about the code.

Th3Coder (68)

@ErrorNoInternet ooh... then just assign a variable to the file.read().splitlines?

Anyways, thanks! I'll try it :)