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