Suppose you see this.
TypeError: 'NoneType' object is not iterable
Instead of guessing, break it down.
TypeError β You're performing an operation on an incompatible type.
NoneType β The value is
None.not iterable β Python expected something it could loop over, like a list or tuple.
A common cause:
def get_users():
print("Loading users...")
for user in get_users():
print(user)
get_users() doesn't return anything, so it returns None by default. Python can't loop over None.When you see this error, ask yourself:
"Which variable was supposed to contain a list but ended up being None?"