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