How-to articles, tricks, and solutions about ITERABLE

In Python, how do I determine if an object is iterable?

In Python, an object is considered iterable if it has an __iter__() method defined or if it has a __getitem__() method with defined indices (i.e., it can be indexed, like a list or a string).

Java: Get first item from a collection

To get the first item from a collection in Java, you can use the iterator() method to get an iterator for the collection, and then call the next() method on the iterator to get the first element.

Python - TypeError: 'int' object is not iterable

This error message is indicating that you are trying to iterate over an object of type 'int', which is not iterable (i.e.