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 | 1859+ Python FAQs | Share
feature | class-and-inheritance | booleans | collection | datetime | aggregating-data-with-functools.reduce() | data-types | context-manager | dataframe-and-series-objects | append | creating-and-starting-threads | basic | async | conditional-statements | syntax-error | pseudocode | __all__-attribute | decimal | oops | control-flow | built-in-modules | operator-and | arbitrary-arguments-(*args,-**kwargs) | loop | advanced-file-operations | counter-function | indexing:-loc-vs-iloc | mathematics | precedence | math | numeric | binary | match | reading-and-writing-large-files-efficiently | logical-operator | id-function | format | random | benefit | split | error-handling | threading | loops | data_structure | print-statement | lambda | logical-operators | pep | nested-loop | return-statement | conditional-statement | quantifiers-(*,-+,-?,-{}) | while-loop | function-argument | enumerate() | access-modifier | list-methods-and-slicing | string-method | functional-programming | max-min | math-copysign | membership-operators-(in,-not-in) | file-handling | zfill-function | exception | rollback | string-formatting | filter | operator-overloading | print | string-manipulation | data-structures-in-python | tuple | sorted | expression | string-methods | postfix | python-module | mapping-function | string-concatenation | walking-through-directories-using-os.walk() | python-history | list-comprehension | control-flow | dictionaries | functional-programming | boolean | logical-operator | data-type | integers | python-repl | introduction-to-multiprocessing | exponentiation | formal-and-actual-parameter | join | input-function | class | memory-management | exception-handling | strings | file_handling | class-and-object | statement | pickling--unpickling | multithreading | overflow | using-map()-for-transformations | assert | assignment-operator | iterable | list-indexing | objects | type-conversion-and-casting | method-overloading | stack | multiple-inheritance | init | python-django | indentation | bitwise-operator | global-variable | software-design | shallow-copy | sorting | using-yield-in-functions | swapping | using-else-and-finally | opening-files-(open()) | working-with-dates-and-times | touples | escape-operator | syntax | intering | method | precedence-and-associativity | default-mutable-argument | reading:-read(),-readline(),-readlines() | string-slicing | list-slicing | recurssion | min-max-function | syntaxerror | managing-directories-with-os-and-shutil | using-the-threading-module | python-operators | gil | slice | comprehension | function-and-scope | installation | virtual-environment | sum() | design-principle | introduction-to-python | creating-custom-modules | center | loop-control | string-method | global | array | interpreter | scientific-notation | global-keyword | boolean-masking | complex-number | list-join | bitwise | pass | error | odd-number | lambda-functions | defining-functions | magic-method | mysql | sys-module | filter-function | operators | data-type-conversions | goto-function | dictionary | numpy | list-mutation | binary-operation | implementation | input-function | range | polymorphism | writing:-write(),-writelines() | class-decorators | yield | list | matrix | directory-operations | keyword | assignment-operators | conditional-statement | collections | static-method | thread-safe-data-structures-(queue.queue) | python-syntax-and-structure | object-attribute | encoding | namespace | tuple-methods | immutability | function | multiprocessing | lambda-function | operator | oop | random-function | staticmethod | loop-control-statements | filtering-and-indexing | class-and-instance-variable | condition | built-in | application | raise-statement | matplotlib | mathematical-function | difference-between-threads-and-processes | descriptors | round | python_version | tuple-unpacking | file-handling | __future__ | parsing-with-strptime | list-vs-tuple | multiple-inheritance | regular-expressions | overriding-methods | while-and-for-loop | import-method | set-operation | typeerror | docstring | type-conversion | asyncio-module | debugging | file | single-inheritance | counter | operator-or | else | zip-function | map-function | datetime.date,-datetime.time,-datetime.datetime | comparison | error-handling | list,-set,-and-dictionary-comprehensions | logical-operation | floats | else-statement | generators-in-python | reading-and-writing-files | classes | def | int | identity-operator | using-lists-as-stacks | deep-copy | arithmetic-operation | string-iteration | operations | pandas | working-with-file-paths | set | sum-function | input | handling-missing-values-(fillna,-dropna) | global-variable | string-formatting | operand | mutable | invalid-list | comment | parameter | __init_subclass__ | round-function | list-operation | asyncio | tuples | python | built-in-function | raise | constructor | frozenset | unit-testing | slicing | while-loops | why-use-multiprocessing-over-threading?-(gil) | package-management | dictionary-comprehensions | expand-tab | memory | thread-synchronization | for | sys | list-comprehension | compute | namedtuple | min-function | zip | joining-and-merging-dataframes | variable | regular-expression | fabs-function | iterators | factorial-function | identity-operators-(is,-is-not) | exception-handling | time-series-with-pandas | thread | generator | formatting-with-strftime | default-arguments | floating-point-precision | choice | inheritance | bitwise-operator | encapsulation | lists | functions | complex | inherit | name-mangling | regex | control-statement | virtual-environment | list-method | literal-characters-and-special-characters | recursion | decorator | test-discovery | module | key-value-pairs | boolean-and-non-boolean | anchors-(^,-$) | dictionary-methods | multiple-except-blocks | matrix-list-comprehension | introduction-to-threads | command-line-parsing | methods | version | sorting-and-ranking | sets | string | string-slicing | using-join()-and-is_alive()-methods | integer | type_conversion | update | while-else-loop | using-os-and-pathlib-modules | version-check | indexing | type-conversion | data-type | using-assertions-(assertequal,-assertraises) | with-statement | data-structure | turtle | working-with-binary-files-(rb,-wb) | attribute | working-with-temporary-files-using-tempfile | syntax-error | data-structure | head-and-tail | copy | built-in-function | data-structures | destructor | arithmetic-expression | higher-order-function | datatype | conversion | lambdas | identifier | heap-memory | library | immutable-data-type | dicts | identity-operator | iterator | call | list-comprehensions | generators ...