I\'ve been trying to make an encryption and decryption system but I have run into a small error. Here is my code:
import sys
import pyperclip
d
local variable 'encrypted' might be referenced before assignment
is a warning generated by the linter.
This is because the linter sees that encrypted
is assigned values inside two if conditions
if question.lower() == 'yes' or question.lower() == 'y':
and
elif question.lower() == 'no' or question.lower() == 'n':
however, the linter cannot know that these two if conditions are complementary to each other. So, considering the case when none of the conditions is true, the variable encrypted
will end up uninitialized.
To get rid of this warning, you can simply initialize the variable before any of the if
conditions with None
value