file = open("app.py")
age = int(input("Age: "))
xfactor = 10 / age
except (ValueError, ZeroDivisionError):
print("you didn't enter a valid age.")
print("No exceprions were thrown.")
PyLint highlights with red “file.close()” in finally block and issues a warning “Using variable ‘file’ before assignmentPylint(E0601:used-before-assignment)”. I need help to understand what’s wrong) I tried to execute this code a few times, and everything worked great.
To address this issue, you can declare the
Example at the beginning:
#Initialize the variable with a default value
file = None or File = “”
E0601 used before assignment:
Description: Emitted when a local variable is accessed before its assignment took place. Assignments in try blocks are assumed not to have occurred when evaluating associated except/finally blocks.
Seems like the the warning you’re getting, Using variable ‘file’ before assignment (E0601:used-before-assignment), you mistakenly edited your code as it worked great. You may be using the wrong variable. Don’t worry, if you are still not getting it. You can prefer CIPD level 3 assignment help UK to write your assignment for you.