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