So I have this text file made up of numbers and words, for example like this - "09807754 18 n 03 aristocrat 0 blue_blood 0 patrician" and I want to split it so that each word or number will come up as a new line.
A whitespace separator would be ideal as I would like the words with the dashes to stay connected.
This is what I have so far:
f = open('words.txt', 'r')
for word in f:
If you do not have quotes around your data:
with open('words.txt','r') as f: for line in f: for word in line.split(): print(word)