Level 9 : What is the output?


x = 10
def outer():
    x = 5
    def inner():
        nonlocal x
        x += 1
        return x
    return inner()

print(outer())

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