Level 3 : What will be the output of this generator function?


def gen():
    for i in range(3):
        yield i
        i += 10

g = gen()
print(list(g))

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