Level 9 : What happens here?


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

print(f())

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