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