TypeError: 'NoneType' object is not iterable in Python

Alex Gordon picture Alex Gordon · Oct 8, 2010 · Viewed 634.7k times · Source

What does error TypeError: 'NoneType' object is not iterable mean?

I am getting it on this Python code:

def write_file(data, filename): # creates file and writes list to it
  with open(filename, 'wb') as outfile:
    writer = csv.writer(outfile)
    for row in data: # ABOVE ERROR IS THROWN HERE
      writer.writerow(row)

Answer

vanza picture vanza · Oct 8, 2010

It means the value of data is None.