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