Does the error occur inside of y = f(x) execution or before? The two first lines of your code work as expected for me.
When I get a TypeError: ‘NoneType’ object is not iterable, it is usually because I forget to write the return statement at the end of a function. In fact functions that return nothing actually return None.