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