Level 1 : What happens if the file is not found in the following Python code?


a=False
while not a:
    try:
        f_n = input("Enter file name")
        i_f = open(f_n, 'r')
    except:
        print("Input file not found")

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