argument of type 'nonetype' is not iterable python code example

Example 1: TypeError: 'NoneType' object is not iterable

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)

Example 2: django if self.pattern.name is not None and ":" in self.pattern.name: TypeError: argument of type 'function' is not iterable

re_path(r'^connect/(?P.+)/(?P\d+)/$', views.change_friends, name='change_friends')

Tags:

Misc Example