iteration, in a simple way, is to access each element of the list individually in some order.
The For statement is a relatively simple way to iterate over time:
Lis = [' A ', ' h ', ' A ', ' I ', ' I ']for x in Lis:print x
This is accessed once for each element in the list.
In addition to the for statement, there is a way to implement the iteration, which is the ITER () method:
Lis = [' A ', ' h ', ' A ', ' I ', ' i ']lis_iter = iter (LIS) Lis_iter.next ()
Lis_iter.next () reads only one element of the list at a time, and then reads the next element when it is executed again. The error occurs until there is no element at the end of the read. Because the pointer does not automatically return to the start position at the end of execution, the next time you use the Iter_iter (). Next () method iterations, the iteration object needs to be re-loaded, which requires re-execution:
Lis_iter = iter (LIS)
Python bit record 9: an iterative approach