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