Level 9 : What will this print?


def numbers():
    yield 1
    raise Exception("Error!")

g = numbers()
print(next(g))
print(next(g))

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