Level 3 : What does this iterator return?


class StepSkipIterator:
    def __init__(self, data, step):
        self.data = data
        self.step = step
        self.index = 0

    def __iter__(self):
        return self

    def __next__(self):
        if self.index >= len(self.data):
            raise StopIteration
        val = self.data[self.index]
        self.index += self.step
        return val

it = StepSkipIterator("Python", 2)
print(list(it))

Author: SandhyaR | Tags: iterator | 1736+ Python FAQs | Share
matrix | sum-function | python-history | turtle | list-join | collections | slice | built-in-function | module | destructor | bitwise | precedence-and-associativity | lambdas | id-function | dictionaries | functional-programming | design-principle | nested-loop | decorator | comment | asyncio | generators-in-python | zip | arithmetic-operation | goto-function | lambda-function | syntaxerror | statement | package-management | binary-operation | version | expand-tab | class-and-inheritance | control-statement | object-attribute | split | indentation | function-and-scope | data-structure | expression | file | fabs-function | objects | call | max-min | loop-control | round-function | bitwise-operator | enumerate() | with-statement | update | math-copysign | raise | sys | matplotlib | memory-management | list-vs-tuple | virtual-environment | set-operation | operator-and | string-manipulation | encapsulation | application | input-function | file_handling | generators | mathematical-function | staticmethod | mysql | parameter | deep-copy | pickling-&-unpickling | filter-function | list-comprehension | __future__ | heap-memory | string-method | threading | keyword | string-formatting | built-in | match | string-iteration | magic-method | tuple-unpacking | control-flow | zip-function | docstring | numeric | lists | format | library | bitwise-operator | conversion | recursion | oop | scientific-notation | rollback | round | decimal | class-and-instance-variable | odd-number | random | mapping-function | identifier | collection | slicing | iterator | identity-operator | syntax-error | formal-and-actual-parameter | virtual-environment | method | mathematics | array | string-method | iterable | installation | exponentiation | benefit | global-variable | python-repl | attribute | higher-order-function | __init_subclass__ | print | asyncio-module | syntax-error | basic | type_conversion | math | immutability | exception-handling | python-django | multithreading | comparison | assert | touples | context-manager | name-mangling | conditional-statement | feature | access-modifier | assignment-operator | center | inheritance | regex | factorial-function | classes | memory | list-mutation | filter | regular-expression | data-structure | condition | return-statement | global-variable | random-function | map-function | list-operation | yield | for | loops | async | datetime | sys-module | python | loop | list-method | python_version | logical-operation | function-argument | operator-or | list | matrix-list-comprehension | init | input-function | namespace | class-and-object | operator | file-handling | control-flow | pandas | polymorphism | counter-function | mutable | def | complex | integer | function | logical-operator | namedtuple | range | identity-operator | built-in-function | lambda | operators | min-max-function | string-slicing | input | numpy | default-mutable-argument | while-loop | string-formatting | boolean | pseudocode | invalid-list | methods | global | exception | sorted | stack | operator-overloading | shallow-copy | while-and-for-loop | escape-operator | print-statement | software-design | gil | sum() | else-statement | datatype | encoding | static-method | join | overflow | floating-point-precision | copy | choice | min-function | command-line-parsing | generator | global-keyword | debugging | indexing | __all__-attribute | exception-handling | sorting | swapping | string-concatenation | type-conversion | list-slicing | complex-number | frozenset | data-structures | functions | type-conversion | string-slicing | dictionary | conditional-statement | class | constructor | head-and-tail | recurssion | multiprocessing | binary | while-else-loop | file-handling | list-comprehension | operations | implementation | logical-operator | import-method | multiple-inheritance | python-module | error | boolean-and-non-boolean | set | append | inherit | syntax | pep | descriptors | data_structure | arithmetic-expression | typeerror | version-check | compute | comprehension | variable | error-handling | postfix | precedence | data-type | dicts | int | immutable-data-type | counter | tuple | zfill-function | string | data-type | list-indexing | operand | thread | interpreter | oops ...