Python error, ‘TypeError: ‘NoneType’ object is not iterable’

Based off what you’ve said, one of these functions is causing an issue:

allTowns = readsFile()
townsList = splitFile(allTowns)

as townsList is defined to None when you attempt to iterate through it inside of searchCounty().

Here’s what’s essentially happening (as done in the python shell):

>>> for i in None:
...     pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable

so you should check that allTowns is right as well as townsList.

Leave a Comment