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