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