how to fix typeerror: nonetype object is not iterable