Level 9 : What happens here?


def f():
    try:
        return 1
    finally:
        return 2

print(f())

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