12/15 purify - warning on cryptic error message


#1

If you accidentally leave off the return statement, you get a very cryptic error message:

"Oops, try again. Your function crashed on [1] as input because your function throws a "'NoneType' object is not iterable" error."


#2

Codecademy calls your purify function to test the result, which it then processes, as if it were a list. But if instead of returning a list, the function returns the value, None, due to the lack of a return statement, Codecademy's test processes the result, anyway, as if it were an iterable type, such as a list, that is composed of components that can each be accessed individually, as in a loop. In the case of the lack of a return statement, when Codecademy attempts to perform a sorting of the items in the purported list, as part of the test, the error gets raised, because the value, None, is not an iterable type.

While that error message might not be particularly helpful without the user's being able to see inside Codecademy's test, the above is the reason for the message.


#3

终于可以不说英文了。。。
一起学习 我才做到9/15


#4

Thanks for the explanation, I suspected it had something to do with the testing....

(In other cases where I have made this mistake, they explicitly caught it.)