'key'변수가 decrypt 함수에 반환되면 왜 인식되지 않습니까?왜 내 파이썬 코드가 "정의되지 않은"오류가 발생합니까?
alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphaList = list(alphabet)
text = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj"
def createKey(aList):
key = []
count = 0
for letter in aList:
if count < 24:
key.append(aList[count + 2])
else:
key.append(aList[count - 24])
count += 1
return key
def decrypt(text):
createKey(alphaList)
decryptedList = []
textList = list(text)
for c in textList:
if c in alphaList:
index = alphaList.index(c)
decryptedList.append(key[index])
else:
decryptedList.append(c)
decryptedText = "".join(decryptedList)
return decryptedText
print decrypt(text)
createKey 함수는 키를 반환하지만'decrypt()'는 반환 값을 캡처하지 않습니다. 'key = createKey (alphaList)'. –
@MarcB 나에게 답을주는 것처럼 들리네. – melwil