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