I'm trying to write a program that will open a text file from the web consisting of 10,000 words, then 'clean' the file to get rid of nonsense words, such as 'aa'. I eventually want to use these words to do other things so I want to add the non 'non-sense' words to be put into a new list. Every time i try to run this I run into the error code TypeError: 'function' object is not iterable
.
import urllib.request
def readWordList():
response = urllib.request.urlopen("http://www.mit.edu/~ecprice/wordlist.10000")
html = response.read()
data = html.decode('utf-8').split()
return data
clean = readWordList()
def clean(aList):
newList = []
for word in aList:
if range(len(word)) >= 2:
newList.append(word)
return newList
clean(clean)