플레이 플레이 암호를 만들려고하고 있지만 올바른 변수에 내 변수를 가져 오는 데 문제가 있습니다.파이썬에서 중첩 목록에 추가
나는 한 번에 2 개의 일반 텍스트를 인코딩하고 인코딩 된 동등 물을 반환하는 함수를 가지고 있지만 한 글자의 2 개의 args 만 허용합니다 (문자열에서). 내 목록을 분리하고 그 쌍을 인코딩하는 데 도움이 필요합니다.
이 내가
def function(plaintext):
temp_hold = ''
encode_out = ''
sendout = ''
#breaks into pairs of 2 (list within a list)
temp_hold = [plaintext[i:i+2] for i in range(0, len(plaintext), 2)]
for i in range(len(temp_hold)):
for j in range(len(temp_hold)):
encode_out = encode_pair(temp_hold[i][j], temp_hold[i][j])
print encode_out
# encode pair takes (a,b) and returns its encoded value
print function("abcd") # should print HSCI
([파이썬에서 중첩 된 목록에 추가]의 중복 가능성 http://stackoverflow.com/questions/13763157/appending-to-a-nested-list-in -python) – lurker