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