def get_common():
'''
Opens the text file containing the list of 1000 most common words found at
http://www.ef.co.uk/english-resources/english-vocabulary/top-1000-words/
removes the newlines and returns them as a list.
'''
text = []
with open('1000common.txt', 'r') as f:
raw_text = f.readlines()
for line in raw_text:
if line.endswith('\n'):
text.append(line[0:-1])
else:
text.append(line)
return text
by using
with open('1000common.txt', 'r') as f:
for line in f:
if line.endswith('\n'):
text.append(line[0:-1])
else:
text.append(line)
return text
We can improve
by using
@etattershall I will let you make the change.