Iterators A container can provide an iterator that provides access to its elements in order iter(iterable):Return an iterator over the elements of an iterable value W >5=[3,4,5j >>t iter(s) next(iterator):Return the next element in an iterator >>next(t) 3 >>next(t) 4 >>u iter(s) >>next(u) 3 >>next(t) 5 >>next(u) n
Iterators 4 A container can provide an iterator that provides access to its elements in order iter(iterable): next(iterator): Return an iterator over the elements of an iterable value Return the next element in an iterator >>> s = [3, 4, 5] >>> t = iter(s) >>> next(t) 3 >>> next(t) 4 >>> u = iter(s) >>> next(u) 3 >>> next(t) 5 >>> next(u) 4
Iterators A container can provide an iterator that provides access to its elements in order iter(iterable):Return an iterator over the elements of an iterable value W >5=[3,4,5j >>t iter(s) next(iterator):Return the next element in an iterator >>next(t) 3 >>next(t) 4 >>u iter(s) >>next(u) 3 >>next(t) 5 >>next(u) (Demo) n
Iterators 4 A container can provide an iterator that provides access to its elements in order iter(iterable): next(iterator): Return an iterator over the elements of an iterable value Return the next element in an iterator >>> s = [3, 4, 5] >>> t = iter(s) >>> next(t) 3 >>> next(t) 4 >>> u = iter(s) >>> next(u) 3 >>> next(t) 5 >>> next(u) 4 (Demo)
Dictionary Iteration
Dictionary Iteration
Views of a Dictionary 6
Views of a Dictionary 6
Views of a Dictionary An iterable value is any value that can be passed to iter to produce an iterator An iterator is returned from iter and can be passed to next;all iterators are mutable 6
Views of a Dictionary 6 An iterable value is any value that can be passed to iter to produce an iterator An iterator is returned from iter and can be passed to next; all iterators are mutable