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