Level 10 : What will be the output of the following code?


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

print(outer())

Author: VenuEmmela | Tags: function | 1736+ Python FAQs | Share
file-handling | string-iteration | return-statement | precedence | regular-expression | data-structures | bitwise-operator | tuple-unpacking | iterable | data_structure | sys | loop | filter-function | default-mutable-argument | while-loop | identity-operator | string-concatenation | input-function | arithmetic-operation | function-and-scope | docstring | filter | init | logical-operation | objects | collections | string-formatting | function | python-repl | package-management | max-min | lambdas | __all__-attribute | rollback | multiprocessing | complex-number | range | memory-management | access-modifier | file | copy | map-function | exception-handling | lambda | math-copysign | list-comprehension | comprehension | formal-and-actual-parameter | indentation | list-indexing | while-else-loop | version | classes | format | odd-number | arithmetic-expression | set | counter-function | global-keyword | version-check | list-comprehension | basic | command-line-parsing | type-conversion | compute | multithreading | installation | match | head-and-tail | else-statement | namespace | python-module | bitwise-operator | conditional-statement | global | __future__ | exponentiation | mathematics | inherit | integer | print | lists | fabs-function | name-mangling | staticmethod | random-function | join | virtual-environment | dictionary | logical-operator | dictionaries | syntax | postfix | functional-programming | interpreter | min-function | string-slicing | data-type | sum() | list | escape-operator | decimal | shallow-copy | sorted | numpy | multiple-inheritance | overflow | complex | list-method | pep | round | assert | software-design | collection | choice | file-handling | goto-function | tuple | python-django | object-attribute | static-method | implementation | statement | generators | sys-module | string-manipulation | async | sorting | import-method | input-function | generators-in-python | def | function-argument | string-slicing | enumerate() | logical-operator | mutable | yield | destructor | conversion | min-max-function | counter | python_version | oops | encapsulation | benefit | operand | regex | condition | mapping-function | for | boolean | lambda-function | operations | pickling-&-unpickling | zfill-function | numeric | module | invalid-list | expression | recurssion | control-flow | input | operator-and | list-slicing | method | list-join | asyncio-module | immutability | control-flow | stack | while-and-for-loop | call | floating-point-precision | operator-or | data-structure | error | feature | datatype | attribute | variable | list-vs-tuple | decorator | virtual-environment | print-statement | built-in-function | update | datetime | library | id-function | expand-tab | pandas | round-function | exception-handling | syntaxerror | file_handling | recursion | syntax-error | string-formatting | swapping | indexing | string-method | immutable-data-type | bitwise | deep-copy | class-and-inheritance | built-in-function | gil | zip | class | class-and-object | descriptors | python | sum-function | memory | constructor | scientific-notation | type-conversion | error-handling | oop | threading | heap-memory | pseudocode | mysql | append | typeerror | with-statement | magic-method | random | binary | debugging | conditional-statement | turtle | encoding | mathematical-function | type_conversion | operator | python-history | inheritance | frozenset | application | operators | int | split | loop-control | dicts | parameter | data-structure | touples | zip-function | design-principle | syntax-error | global-variable | list-operation | exception | nested-loop | string | __init_subclass__ | polymorphism | control-statement | binary-operation | array | built-in | matplotlib | matrix | center | boolean-and-non-boolean | context-manager | functions | math | loops | comparison | keyword | methods | slicing | thread | identity-operator | raise | matrix-list-comprehension | class-and-instance-variable | assignment-operator | slice | higher-order-function | list-mutation | namedtuple | iterator | comment | data-type | operator-overloading | asyncio | identifier | set-operation | generator | global-variable | factorial-function | precedence-and-associativity | string-method ...