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