Level 10 : What will this code output?


def double_yield():
    yield 1
    yield from [2, 3, 4]
    yield 5

g = double_yield()
print(list(g))

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