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