__iter__
method, or
__getitem__()
and __len__()
. Such objects are referred to as sequences list
, tuple
and str
as well as the non-sequence type dict
or file objects. __next__
method. iter()
built-in function. next()
function. lst = [ 'one', 'two', 'three', 'four', 'five' ] itr = iter(lst) one = next(itr) rst = list(itr) print(one) # # one print(type(rst)) # # <class 'list'> print(rst) # # ['two', 'three', 'four', 'five']