Why do I get this error “TypeError: ‘method’ object is not iterable”?

You misunderstand the error message: It doesn’t say that a list would not be iterable, it says that a method isn’t.

What happens is that your pieces list doesn’t contain pieces but references to the add_piece method because you forgot to call the method when you wanted to append its result in line 56.

You could have found this error even having less experience with exception types by invoking a debugger (pdb) just before the line that raises the error.

Leave a Comment

tech