TypeError: 'NoneType' object is not iterable. Why