Level 9 : what is the output of the following code?


def creating_gen(index):  
    months = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']  
    yield months[index]  
    yield months[index+2]  
next_month = creating_gen(3)  
print(next(next_month), next(next_month))

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