collection data types been created (an implementation of real sorted dictionary that automatically maintains its keys in sorted order is presented in iterating and copying collections ||once we have collections of data itemsit is natural to want to iterate over all the items they contain in this section' first subsection we will introduce some of python' iterators and the operators and functions that involve iterators another common requirement is to copy collection there are some subtleties involved here because of python' use of object references (for the sake of efficiency)so in this section' second subsectionwe will examine how to copy collections and get the behavior we want iterators and iterable operations and functions |an iterable data type is one that can return each of its items one at time any object that has an __iter__(methodor any sequence ( an object that has __getitem__(method taking integer arguments starting from is an iterable and can provide an iterator an iterator is an object that provides __next__(method which returns each successive item in turnand raises stopiteration exception when there are no more items table lists the operators and functions that can be used with iterables the order in which items are returned depends on the underlying iterable in the case of lists and tuplesitems are normally returned in sequential order starting from the first item (index position )but some iterators return the items in an arbitrary order--for exampledictionary and set iterators the built-in iter(function has two quite different behaviors when given collection data type or sequence it returns an iterator for the object it is passed--or raises typeerror if the object cannot be iterated this use arises when creating custom collection data typesbut is rarely needed in other contexts the second iter(behavior occurs when the function is passed callable ( function or method)and sentinel value in this case the function passed in is called once at each iterationreturning the function' return value each timeor raising stopiteration exception if the return value equals the sentinel when we use for item in iterable looppython in effect calls iter(iterableto get an iterator this iterator' __next__(method is then called at each loop iteration to get the next itemand when the stopiteration exception is raisedit is caught and the loop is terminated another way to get an iterator' next item is to call the built-in next(function here are two equivalent pieces of code (multiplying the values in list)one using for in loop and the other using an explicit iterator__iter__(