Level 9 : What happens here?


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

print(f())

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