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