I am getting a syntax error in a try suite on a variable created within the try suite. Is it not correct to call a variable in the except suite that was created in the try suite? This is the only reason I could think of that there would be a syntax error for that variable.
try:
file_name = input('Enter the encrypted file: ')
encryptionKey = open(input('Enter the file name for theencryptionkey: '),'r')
anEncryptedLine = open(file_name)
decrypted_file = open(decrypted_file.txt,'a+')
decrypted_str = ''
for i in decrypted_file:
decrptyed_line =substitutionDecrypt(i)
print(decrypted_line, file=decrypted_file.txt)
except IOError:
print('The file 'file_name'doesn\'nt exist')
The syntax error is appearing on the variable 'file_name' in the last line
Thanks