I'm trying to get my code to return when my if statement isn't met. In other words, when my loop gets to the else statement, it throws the following error:
Oops, try again. Your function crashed on  as input because your function throws a "'NoneType' object is not iterable" error.
I expected the code to return from the else statement and back into the for loop.
I can replace my else: return with an else: print('') and it runs fine. I don't understand why that is.
def purify(dirty): clean= for i in range(len(dirty)): if dirty[i] % 2 == 0: clean.insert(i, dirty[i]) else: return return clean