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