Ask coding questions

← Back to all posts
How can I make a big so every word is a different string without having too put 1 million "
Alesteve33 (0)

for example: I have this words:

uppity
attract
unable
receive
groovy
excite
rude

and I want to make them like:

"uppity",
"attract",
"unable",
"receive",
"groovy",
"excite",
"rude",

Comments
hotnewtop
ch1ck3n (2069)

first, put your words in a file called wordlist.txt.

wordlist = open("wordlist.txt", "r").read()
wordarray = []
for p in wordlist:
  wordarray.append(p.replace('\r', ' ').replace('\n', ' '))
wordlist = ''.join(wordarray)
print(wordlist.split(" "))
19ecal (232)

Presumably you want to put them in a list, so try putting them in words.txt, then you can turn it into a python list like this

with open("words.txt", "r") as f:
    words=f.read().split("\n")
xfinnbar (82)

What programming language?

xxpertHacker (930)

@xfinnbar They only use Python, so it should be safe to assume.

notGilbert (121)

You could try putting it in a file, reading it and splitting it by newline