Python lists are not iterators.

Last Updated On Thursday 20th Jan 2022

TypeError: ‘list’ object is not an iterator

The list is not an iterator.The list, range object, and dict.keys() are definitely called Iterable. Iterables can be passed to .for in ...

Between iterables and iterators.

list iterator python

  • iter(...) what you can do is iterable.
  • next(...) what you can do is iterator.

Iterator manage the loop situation instead of the list itself.

  • Iterators are also iterable at the same time. so you can pass the iterator to .
  • In this case, the iterator returns itself when it does .for in ...iter(my_iterator)my_iterator

Iterator not (iterable)

  • string
  • list
  • tuple
  • range object
  • dictionary, dictionary.keys(), dictionary.values(), dictionary.items()
  • assembly