I want to use the variable "i" created in poss = [j.split() for j in [decipher(i, txt) for i in range(1, 26)]]
, but it raises a NameError when I try to access it in line return f"The key is {i} and the deciphered text is{' '.join(k)}."
. Is there any way to do this without raising an error?
popular = open("C:/Users/NAME/FilesForPyCharm/popular.txt")
words = [line.strip() for line in popular]
poss = [j.split() for j in [decipher(i, txt) for i in range(1, 26)]]
for k in poss:
if set(k).issubset(set(words)):
return f"The key is {i} and the deciphered text is{' '.join(k)}."