Level 9 : What happens here?


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

print(f())

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