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