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