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