Level 10 : 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 | 1736+ Python FAQs | Share
touples | collections | decimal | tuple-unpacking | call | format | virtual-environment | context-manager | return-statement | syntax-error | identifier | string-method | data-structure | goto-function | memory | turtle | classes | encoding | memory-management | expand-tab | numeric | debugging | built-in-function | precedence | pandas | random-function | objects | iterable | global-keyword | type_conversion | counter-function | scientific-notation | parameter | heap-memory | id-function | binary | static-method | syntax-error | dictionary | match | list-comprehension | variable | module | data-structure | overflow | list | python-repl | sum() | docstring | software-design | identity-operator | recurssion | lambda | namespace | pickling-&-unpickling | sorting | sys | datatype | loop-control | file-handling | shallow-copy | enumerate() | input | while-else-loop | destructor | min-function | print-statement | set | yield | sorted | math | filter | int | list-operation | design-principle | object-attribute | else-statement | binary-operation | python | class | list-indexing | numpy | default-mutable-argument | deep-copy | mathematics | installation | file_handling | string-formatting | library | statement | string | operator-overloading | copy | center | name-mangling | operations | generator | benefit | keyword | string-method | type-conversion | loop | control-flow | error-handling | functions | immutability | boolean-and-non-boolean | join | multithreading | compute | decorator | precedence-and-associativity | application | arithmetic-expression | postfix | list-mutation | file | global | oops | logical-operator | swapping | higher-order-function | pep | condition | mapping-function | dictionaries | regular-expression | floating-point-precision | built-in-function | append | tuple | boolean | syntax | class-and-inheritance | control-statement | comprehension | typeerror | package-management | stack | immutable-data-type | class-and-object | string-iteration | operators | random | string-concatenation | __future__ | set-operation | asyncio-module | staticmethod | formal-and-actual-parameter | assignment-operator | gil | odd-number | comparison | arithmetic-operation | attribute | raise | list-comprehension | conditional-statement | python-django | error | virtual-environment | invalid-list | operator | sys-module | max-min | input-function | datetime | logical-operator | global-variable | integer | array | built-in | round | string-manipulation | implementation | nested-loop | update | filter-function | namedtuple | encapsulation | complex-number | function-argument | generators-in-python | conditional-statement | factorial-function | comment | version | identity-operator | mathematical-function | sum-function | def | operator-and | fabs-function | matrix | collection | indexing | slicing | inheritance | magic-method | operand | lists | regex | split | python-history | list-join | syntaxerror | feature | bitwise-operator | input-function | type-conversion | file-handling | list-method | counter | indentation | exception-handling | version-check | lambdas | lambda-function | function-and-scope | assert | string-slicing | threading | choice | command-line-parsing | min-max-function | recursion | list-vs-tuple | pseudocode | init | data-type | map-function | constructor | matrix-list-comprehension | asyncio | oop | method | async | interpreter | mysql | list-slicing | iterator | loops | inherit | python-module | bitwise-operator | operator-or | zip-function | zip | matplotlib | string-formatting | exception | polymorphism | methods | exponentiation | descriptors | round-function | __all__-attribute | expression | data-structures | function | escape-operator | basic | multiprocessing | zfill-function | slice | python_version | exception-handling | range | math-copysign | multiple-inheritance | complex | frozenset | __init_subclass__ | for | access-modifier | print | class-and-instance-variable | import-method | control-flow | while-loop | data-type | rollback | functional-programming | head-and-tail | string-slicing | data_structure | with-statement | logical-operation | mutable | bitwise | conversion | while-and-for-loop | thread | generators | global-variable | dicts ...