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