Level 10 : What is the output for the below code?


def gen():
    yield from range(3)
    yield 10

print(list(gen()))

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