What is the difference between iterator and iterable and how to use them?

I know this is an old question, but for anybody reading this who is stuck with the same question and who may be overwhelmed with all the terminology, here’s a good, simple analogy to help you understand this distinction between iterables and iterators:

Think of a public library. Old school. With paper books. Yes, that kind of library.

A shelf full of books would be like an iterable. You can see the long line of books in the shelf. You may not know how many, but you can see that it is a long collection of books.

The librarian would be like the iterator. He can point to a specific book at any moment in time. He can insert/remove/modify/read the book at that location where he’s pointing. He points, in sequence, to each book at a time every time you yell out “next!” to him. So, you normally would ask him: “has Next?”, and he’ll say “yes”, to which you say “next!” and he’ll point to the next book. He also knows when he’s reached the end of the shelf, so that when you ask: “has Next?” he’ll say “no”.

I know it’s a bit silly, but I hope this helps.