Level 9 : What happens here?


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

print(f())

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