I'm trying to write code to check a list for any odd numbers, and then add all the even numbers to a new list and then print the new list. However, I'm getting an error that my program crashes on [1]. This tells me that the program worked on index 0.. or at least I believe it did. Does anybody have any ideas on why I'm getting this error and why it's not iterating through my whole list?
Thanks
def purify(list):
> def is_odd(list):
> newList = []
> for item in list:
> if item %2 != 0:
> is_odd = True
> for word in list:
> if is_odd == True:
> break
> else:
> is_odd= False
> newList.append(word)
> print newList
Error: Your function crashed on [1] as input because your function throws a "'NoneType' object is not iterable" error