Level 5 : What is the output for the below code?


def foo():
    try:
        raise ValueError("An error")
    except ValueError:
        return "Caught"
    finally:
        return "Finally"

print(foo())

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